LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

ComRdByte

int ComRdByte (int portNumber);

Purpose

Reads a byte from the input queue of the port you specify.

Returns an integer whose low-order byte contains the byte read. Returns on timeout, when the byte is read, or when an error occurs. If an error or a timeout occurs, ComRdByte returns a negative error code. This is the only case in which the high-order byte of the return value is nonzero.

ComRdByte times out whenever the input queue remains empty for an entire timeout period. On a timeout, ComRdByte returns -99. You can set the timeout period by calling SetComTime.

ComRdByte returns an error code if you have not opened the port, if you pass an invalid parameter value, or if a timeout occurs.

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.

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
byte int The byte read from the selected port, unless an error occurs.

If an error occurs the return value is a negative error code.

Additional Information

Library: RS-232 Library

Include file: rs232.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Log in to get a better experience