Quantcast
Viewing all articles
Browse latest Browse all 27212

Detecting Disconnection of USB Serial Device

I am connected to an Arduino board via a USB link. My code catches exceptions when the USB cable is disconnected and any code references the SerialPort object. This works fine, but what is the simplest way of detecting when the Serialport object disappears so that I can rescan the available ports, list them to the user and flash a message to the effect that the device has been disconnected? I found a reference in a search to capturing the "WM_DEVICECHANGE message". Would this be the way to go about doing this?

Viewing all articles
Browse latest Browse all 27212


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>