Question

I was wondering if there was any function along the lines of IsBufferEmpty() to use on a synchronous handle rather than using ReadFile() and waiting for it to return false. I need something to eliminate the delay that ReadFile() takes to try to read data.

Was it helpful?

Solution

Is this for serial port communication?

If so, you can use the ClearCommError() function:

DWORD com_errors = 0;
COMSTAT com_stat;

ClearCommError(serial_port_handle, &com_errors, &com_stat);
/* com_stat.cbInQue now holds the number of characters in the receive buffer */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top