Your browser does not allow scripts
Please click here to view a static table of contents without scripts
FT_W32_ClearCommError
Return to Introduction  Previous page  Next page
Gets information about a communications error and get current status of the device.

BOOL
FT_W32_ClearCommError
(FT_HANDLE ftHandle, LPDWORD lpdwErrors, LPFTCOMSTAT lpftComstat)




Parameters
ftHandle
Handle of the device.
lpdwErrors
Variable that contains the error mask.
lpftComstat
Pointer to FTCOMSTAT structure.




Return Value
If the function is successful, the return value is nonzero.
If the function is unsuccessful, the return value is zero.

Example
This example shows how to use this function.

static COMSTAT oldCS = {0};
static DWORD dwOldErrors = 0;

FT_HANDLE ftHandle; // setup by FT_W32_CreateFile
COMSTAT newCS;
DWORD dwErrors;
BOOL bChanged = FALSE;

if (!FT_W32_ClearCommError(ftHandle, &dwErrors, (FTCOMSTAT *)&newCS))
  ; // FT_W32_ClearCommError failed

if (dwErrors != dwOldErrors) {
  bChanged = TRUE;
  dwErrorsOld = dwErrors;
}

if (memcmp(&oldCS, &newCS, sizeof(FTCOMSTAT))) {
  bChanged = TRUE;
  oldCS = newCS;
}

if (bChanged) {
  if (dwErrors & CE_BREAK)
    ; // BREAK condition detected
  if (dwErrors & CE_FRAME)
    ; // Framing error detected
  if (dwErrors & CE_RXOVER)
    ; // Receive buffer has overflowed
  if (dwErrors & CE_TXFULL)
    ; // Transmit buffer full
  if (dwErrors & CE_OVERRUN)
    ; // Character buffer overrun
  if (dwErrors & CE_RXPARITY)
    ; // Parity error detected
  if (newCS.fCtsHold)
    ; // Transmitter waiting for CTS
  if (newCS.fDsrHold)
    ; // Transmitter is waiting for DSR
  if (newCS.fRlsdHold)
    ; // Transmitter is waiting for RLSD
  if (newCS.fXoffHold)
    ; // Transmitter is waiting because XOFF was received
  if (newCS.fXoffSent)
    ; //
  if (newCS.fEof)
    ; // End of file character has been received
  if (newCS.fTxim)
    ; // Tx immediate character queued for transmission
  // newCS.cbInQue contains number of bytes in receive queue
  // newCS.cbOutQue contains number of bytes in transmit queue
}