How can I discover, using C#’s SerialPort class, whether a device is connected to a specific serial (COM) port?
Note: that class’s Open method opens the port even if there is no device connected to the port.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer depends on the device and the cable.
In some cases, DSR (
SerialPort.DsrHolding) or even CTS (SerialPort.CtsHolding) will be raised when the device is connected.But in some cases you may only have Tx / Rx connected, and the only way to tell is to attempt to communicate with the device.
You need to look at the documentation for your device and its cable.
There’s no general solution that works for any device.