How to read if USB cables or relay are connected or not using c#?

197 Views Asked by At

I have usb cable connected to pc. This is not device, only cables. I need to know if some of them are connected or not using c# program. I dont know which cables. If some of usb pins (i dont know which) are connected c# app should show ON and if are not connected to itself - OFF. Or maybe should i use for that purpose some ftdi usb to com cable? I have only usb ports in PC. I dont know about it too much. Thanks.

1

There are 1 best solutions below

0
On

I think that the closest you can get to the functionality you are seeking is:

string[] ports = System.IO.Ports.SerialPort.GetPortNames();

This will return you a list of names of the COM-ports of the connected devices. You will need some sort of user input to figure out how many cables are connected and use that info along with ports to make your application.

Detecting an unconnected cable is not possible on regular PCs.