INtime SDK Help
ReadComm (Serial Communications)
INtime SDK v7.1 > About INtime > Networking and I/O > Serial Communications (COMM) > ReadComm (Serial Communications)

Reads data from a communications device.

BOOLEAN ReadComm(
  COMMHANDLE hComm,                // handle to device
  LPVOID lpBuffer,                 // data buffer
  DWORD nNumberOfBytesToRead,      // number of bytes to read
  LPDWORD lpNumberOfBytesRead,     // number of bytes read
  LPVOID lpOverlapped              // unused
);

Parameters

hComm
[in] Handle to the device to be read.
lpBuffer
[out] Pointer to the buffer that receives the data read from the file.
nNumberOfBytesToRead
[in] Specifies the number of bytes to read from the file.
lpNumberOfBytesRead
[out] Pointer to the variable that receives the number of bytes read. ReadComm sets this value to zero before doing any work or error checking.
lpOverlapped
[in] Unused.

Return Values

Non-zero
Success.
0 (zero)
Failure. To determine the status, call GetLastRtError.

This function returns when the number of bytes requested has been read, or an error occurs.

Remarks

The behavior of ReadComm is governed by the current communication time-outs as set and retrieved using SetCommTimeouts and GetCommTimeouts. Unpredictable results can occur if you fail to set the time-out values. For more information about communication time-outs, see the COMMTIMEOUTS structure.

If ReadComm succeeds but NumberOfBytesRead is 0, determine if the EOF character has been received by calling ClearCommError, then examing the fEof field in COMSTAT.

Status

E_BUSY
A read operation is already in progress
E_DISCONNECTED
COMM channel is closed
E_IO
A hardware error occurred
E_PARAM
Invalid parameter

Requirements

Versions Defined in Include Link to
INtime 3.1 intime/rt/include/comm.h comm.h comm.lib
See Also