Knowing the serial port Plug/Unplug status
-
Hi , I am facing a problem. In my MFC application I have to check whether serial port is in Plugged/Unplugged status. Any method for finding it? any window message or event for knowing serial port status? Thanx in advance
-
Hi , I am facing a problem. In my MFC application I have to check whether serial port is in Plugged/Unplugged status. Any method for finding it? any window message or event for knowing serial port status? Thanx in advance
Hello. There are status signals you can test, such as DSR (Data Set Ready) and CTS (Clear To Send) (Provided you did set RTS (Request To Send) high first). If there are a device connectoed to the port, those staus signals should indicate the port is connected to a powered on device. But in my experience, the status signals aren't 100% trustworthy when the serial port is unplugged. What's worse, it seems as their state depends on the hardware. So the best way to find out, is to send some kind of status question to the device, then wait for an answer. If you get an answer, it's definately plugged in.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson