GetComStat

int GetComStat (int COMPort);

Purpose

Returns information about the status of a COM port.

The library accumulates COM port conditions until you call GetComStat.

GetComStat returns a negative error code if you have not opened the port of if you pass an invalid value for COMPort.

Parameters

Input
Name Type Description
COMPort integer A number that indicates the COM port on which to operate.

This number is paired with deviceName, which represents the COM port, during the OpenComConfig function call.

Default Value: 1—COM1
Valid Range: 1—1,000

Return Value

Name Type Description
comPortStatus integer Hardware-specific information about the status of the selected port.

The status word is comprised of individual bits, each with a different meaning. Several bits can indicate the presence of more than one condition. The following table shows the hexadecimal value of the bit and its corresponding description:

Hex Value Mnemonic Description
0001 INPUT LOST Input queue filled and input characters lost; you did not remove characters fast enough.
0002 ASYNCH ERROR Problem determining number of characters in input queue. This is an internal error and normally should not occur.
0010 PARITY Parity error detected.
0020 OVERRUN Overrun error detected; a character was received before the receiver data register was emptied.
0040 FRAMING Framing error detected; stop bits were not received when expected.
0080 BREAK Break signal detected.
1000 REMOTE XOFF XOFF character received. If you enabled XON/XOFF, no characters are removed from the output queue and sent to the other device until that device sends an XON character. Refer to SetXMode.
2000 REMOTE XON XON character received. If you enabled XON/XOFF, characters are removed from the output queue and sent to the other device until that device sends an XOFF character.
4000 LOCAL XOFF XOFF character sent. If you enabled XON/XOFF, XOFF is transmitted when the input queue reaches 90% of its capacity. If the other device is sensitive to XON/XOFF protocol, it transmits no more characters until it receives an XON character. You use this process to avoid the INPUT LOST error.
Note  LabWindows/CVI passes the input queue size and output queue size information from the OpenComConfig function to the Windows serial driver. However, the Windows serial driver might use a different number for the actual queue size. Because the driver sends the XOFF and XON characters based on the actual queue size, the driver might not transmit an XOFF or XON character when you expect.
8000 LOCAL XON XON character sent. If you enabled XON/XOFF, XON is transmitted when the input queue falls below 10% of its capacity. If the other device is sensitive to XON/XOFF protocol, it transmits characters until it receives an XOFF character. You use this process to avoid the INPUT LOST error.

Notice the ambiguity in this status information. If an error occurs on the indicated port, your application program knows that one or more bytes are invalid. Your program cannot determine from the status word which byte read is invalid.

GetComStat returns a negative error code if you have not opened the port of if you pass an invalid value for COMPort.