I’m calling Win32 ReadFile to read from a Windows serial port. If my device is unplugged, ReadFile still returns success. How can I check if the connection to the device has been lost? I could do this by sending a message and not getting a response or listening for device events but is there any more straightforward way?
Share
Serial ports are dumb in that there is no device independent way of knowing when something is or is/not plugged into the serial port. Because of this, most devices that use serial ports support some kind of communication protocol which will allow you to determine if something is connected or not.