LabWindows/CVI

GetComStat

int GetComStat (int portNumber);

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 or if you pass an invalid value for portNumber.

Parameters

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

This number maps to the COM port specified by deviceName in the call to OpenCom or OpenComConfig. The portNumber 1, for example, may not necessarily map to COM1.

(Linux) The portNumber 1, for example, may not necessarily map to /dev/ttyS0.

Valid Range: 1—1,000

Return Value

Name Type Description
comPortStatus int 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 Windows Input queue filled and input characters lost; you did not remove characters fast enough.
0010 PARITY Parity error detected.
0020 OVERRUN Windows and RT 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 Windows Transmission is in a suspended state because an XOFF character was received from the remote device. No characters will be removed from the output queue and sent to the device until an XON character is received. Note that this status is only returned if the port has enabled XON/XOFF handshaking. Refer to SetXMode for more information about handshaking.
4000 LOCAL XOFF Windows The driver sent an XOFF character and is waiting for the input queue to fall to 10% of its capacity. 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.

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 or if you pass an invalid value for portNumber.

Additional Information

Library: RS-232 Library

Include file: rs232.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Example

Refer to rs232\serial.cws for an example of using the GetComStat function.