The standard library has a function

ReadFile (hCom, // number of bytes to read inputData, // number of bytes, read by
// pointer to number of bytes read NULL) // pointer to structure for data

But this function has one big drawback - we need to know the exact amount of information we need to accept. If you tell the function to read information, but there is no information, the function will wait for this information for a very long time. In my case, this is communication with the device through the com port.

Maybe you know another function that reads the com port only if there is something to read. And if not, then goes on the program?

  • And if msdn read? On the topic of asynchronous operations ... - alexlz

1 answer 1

A good article on how to work with COM using WINAPI : Working with a COM port using threads .