ReadComm

int ReadComm(idComDev, lpvBuf, cbRead)

int

idComDev;

/* ID of the device to be read */

void FAR * lpvBuf;

/* Address of the buffer from which bytes are read */

int

cbRead;

/* Number of bytes to read */

The ReadComm function will read the byte data from the specified communication device and assume the specified number is the maximum bytes.

<Parameter >

idComDev: Specifies the device to be read. The OpenComm function returns this value.

lpvBuf: Pointer to the buffer from which the bytes are read.

cbRead: Specifies the number of bytes to read.

<Return value >

This function returns the number of bytes having been read if the function is terminated normally. Otherwise it returns a value less than zero, and the absolute value of the return value indicates the number of bytes that were read.

Note:

If an error occurs, the user can survey the cause of the error by acquiring the error value and status via the GetCommError function. Since an error may occur if no bytes are present in the buffer, always make sure that an error has not occurred using the GetCommError function, even if the return value is 0. The return value can be less than the number specified by the cbRead parameter only if it is greater than the received number of bytes in the queue. If the return value is equal to cbRead, some additional bytes for the device may remain in the device queue. If the return value is 0, no bytes remain.

Note on IrDA:

Since the communication flow is controlled according to IrDA protocol, the reception buffer will not cause an overflow.

124

Page 124
Image 124
Casio IT-2000W manual ReadComm