National Instruments 320682C Musical Toy Instrument User Manual


 
Chapter 5 RS-232 Library
© National Instruments Corporation 5-11 LabWindows/CVI Standard Libraries
ComRd
int
nbytes = ComRd
(int
COMPort
,
char
buffer
[],
int
count
);
Purpose
Reads
count
bytes from input queue of the specified port and stores them in
buffer
. Returns
either on time-out or when
count
bytes have been read. Returns an integer value indicating the
number of bytes read from queue.
Parameters
Input
COMPort
integer Range 1 through 16.
count
integer 0 value takes no bytes from
queue.
Output
buffer
string The buffer in which to store the
data.
Return Value
nbytes
integer Number of bytes read from the
input queue.
Using This Function
This function times out if the input queue remains empty in the specified time-out period. This
may occur when no data has been received within the time-out period.
The function returns an error code if the port is not open or parameter values are invalid.
Example
/* Read 100 bytes from input queue of COM1 into buf. */
int n;
char buf[100];
:
n = ComRd (1, buf, 100);
if (n != 100)
/* Time-out or error occurred before read completed. */ ;