GetCommError

2.x

  int GetCommError(idComDev, lpStat)    
  int idComDev; /* communications device identifier */
  COMSTAT FAR* lpStat; /* address of device-status buffer */

The GetCommError function retrieves the most recent error value and current status for the specified device.

When a communications error occurs, Windows locks the communications port until GetCommError clears the error.

Parameters

idComDev

Specifies the communications device to be examined. The OpenComm function returns this value.

lpStat

Points to the COMSTAT structure that is to receive the device status. If this parameter is NULL, the function returns only the error values. The COMSTAT structure has the following form:

typedef struct tagCOMSTAT {   /* cmst                            */
    BYTE status;              /* status of transmission          */
    UINT cbInQue;             /* count of characters in Rx Queue */
    UINT cbOutQue;            /* count of characters in Tx Queue */
} COMSTAT;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

Return Value

The return value specifies the error value for the most recent communications-function call to the specified device, if GetCommError is successful.

Errors

The return value can be a combination of the following values:

Value Meaning

CE_BREAK Hardware detected a break condition.
CE_CTSTO CTS (clear-to-send) timeout. While a character was being transmitted, CTS was low for the duration specified by the fCtsHold member of the COMSTAT structure.
CE_DNS Parallel device was not selected.
CE_DSRTO DSR (data-set-ready) timeout. While a character was being transmitted, DSR was low for the duration specified by the fDsrHold member of COMSTAT.
CE_FRAME Hardware detected a framing error.
CE_IOE I/O error occurred during an attempt to communicate with a parallel device.
CE_MODE Requested mode is not supported, or the idComDev parameter is invalid. If set, CE_MODE is the only valid error.
CE_OOP Parallel device signaled that it is out of paper.
CE_OVERRUN Character was not read from the hardware before the next character arrived. The character was lost.
CE_PTO Timeout occurred during an attempt to communicate with a parallel device.
CE_RLSDTO RLSD (receive-line-signal-detect) timeout. While a character was being transmitted, RLSD was low for the duration specified by the fRlsdHold member of COMSTAT.
CE_RXOVER Receiving queue overflowed. There was either no room in the input queue or a character was received after the end-of-file character was received.
CE_RXPARITY Hardware detected a parity error.
CE_TXFULL Transmission queue was full when a function attempted to queue a character.

See Also

OpenComm