0

I am currently working on a C# program that is responsible for monitoring COM ports. In case of an error condition, the connected device should be restarted. For this purpose, all relevant devices are connected to the computer using a programmable Pegasus USB Hub. This hub allows individual ports to be turned on and off using a serial interface. However, since I don't know which physical port the devices are connected to, I need a way to map the Device Instance Path (ex. USB\VID_0AB4&PID_0010\IG011556) which I have, to their corresponding Location paths (ex. PCIROOT(0)#PCI(1D04)#USBROOT(0)#USB(4)) which I don't have. The location path will then allow me to determine on which physical port the device is connected and trigger a power cycle. Both of the mentioned attributes can be found in the device properties window of the device manager.

I have tried to find the data in the registry at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\DEVICE_ID and its subkeys. I was able to find the LocationInformation data (ex. Port_#0003.Hub_#0006) there, it matches the information in the device properties window. Example. However this information is insufficient, as some devices break the pattern and display different infomation (ex. 0000.0013.0002.001.000.000.000.000.000). I tried searching with Regedit for exact string displayed in the device properties but was not able to find it in the registry. I also looked for information in the Win32_PnPEntity or Win32_USBHub classes but there seems to be no additional infos there. I have read somewhere that it may be possible using the setupapi but I have found no examples and couldn't figure it out myself. Any ideas?

SourceC0de
  • 31
  • 7
  • A USB device has a Header which gives manufacturer information. In most cases it will give the Manufacturer and model. Some devices will also give serial number. You should always use the manufacturer Drive and not the generic Microsoft Driver. The manufacturer driver will give more info than the generic driver. Many manufactures driver will access internal registers that the generic drive will not access., To identify a device you should use the info in the header and not the path. – jdweng Jul 27 '23 at 15:51
  • Found a solution and and posted it here: https://stackoverflow.com/a/76787479/21952181 – SourceC0de Jul 28 '23 at 11:44

0 Answers0