int ComRd (int COMPort, char buffer[], int count);
Reads count bytes from the input queue of the port you specify and stores them in buffer. Returns on timeout or when count bytes have been read. Returns an integer value that indicates the number of bytes read from queue.
ComRd times out when the input queue remains empty for an entire timeout period. On a timeout, ComRd returns the number of bytes actually written and sets rs232err to -99. To set the timeout period, call SetComTime. ComRd returns an error code if you have not opened the port or if you pass an invalid parameter value.
/* Read 100 bytes from input queue of COM1 into buf. */
int n;
char buf[100];
.
.
.
n = ComRd (1, buf, 100);
if (n != 100)
/* Timeout or error occurred before read completed. */;
![]() |
Note When executing a transfer less than 8 bits, LabWindows/CVI does not guarantee the value of the invalid high bits. For a 7 bits transfer, the value of the 8th bit is undefined. 7 bit value "0x60" can be passed back as "0x60" or"0xE0"(0x60|0x80). This depends on the device driver. Most drivers set the value to 0. |
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 |
count | integer | The number of bytes to read from the selected port. Specifying 0 takes no bytes from queue. |
Output | ||
Name | Type | Description |
buffer | string | The variable in which to store the data that was read from the selected port. |
Name | Type | Description |
nbytes | integer | Number of bytes read from the input queue. If an error occurs, the return value is a negative error code. |