GetCommError

Syntax

int GetCommError(nCid,lpStat)

In case of a communications error, Windows locks the communications port until the error is cleared by using the GetCommError function. This function fills the status buffer pointed to by the lpStat parameter with the current status of the communication device specified by the nCid parameter. It also returns the error codes that have occurred since the last GetCommError call. If lpStat is NULL, only the error code is returned. For a list of the error codes, see Table 4.8, “Communications Error Codes.”

Parameter Type/Description  

nCid int Specifies the communication device to be examined. The OpenComm function returns this value.  
lpStat COMSTAT FAR * Points to the COMSTAT structure that is to receive the device status. The structure contains information about a communication device.  

Return Value

The return value specifies the error codes returned by the most recent communications function. It can be a combination of one or more of the values given in Table R.8.

Table R.8 Communications Error Codes

Value Meaning

CE_BREAK The hardware detects a break condition.
CE_CTSTO Clear-to-send timeout. CTS is low for the duration specified by CtsTimeout while trying to transmit a character.
CE_DNS The parallel device is not selected.
CE_DSRTO Data-set-ready timeout. DSR is low for the duration specified by DsrTimeout while trying to transmit a character.
CE_FRAME The hardware detects a framing error.
CE_IOE An I/O error occurs while trying to communicate with a parallel device.
CE_MODE Requested mode is not supported, or the nCid parameter is invalid. If set, this is the only valid error.
CE_OOP The parallel device signals that it is out of paper.
CE_OVERRUN A character is not read from the hardware before the next character arrives. The character is lost.
CE_PTO Timeout occurs while trying to communicate with a parallel device.

Table R.8 Communications Error Codes (continued)

Value Meaning

CE_RLSDTO Receive-line-signal-detect timeout. RLSD is low for the duration specified by RlsdTimeout while trying to transmit a character.
CE_RXOVER Receive queue overflow. There is either no room in the input queue or a character is received after the EofChar character is received.
CE_RXPARITY The hardware detects a parity error.
CE_TXFULL The transmit queue is full while trying to queue a character.