0

I have a device with a USB port and I'm using a WPF app to communicate with it. Now when the user executes my program it can detect all the available ports and let the user to choose from a drop down menu. The device in this case is this.

So far it is fine, but in this case the user has to first go to Device Manager and figure out the port of the device before selecting and connecting in my program.

Is there also a way that my program can automatically detect the particular device's port? (I guess in my program I need some info about the device but what I don't know).

user1245
  • 107
  • 4
  • Make sure you are using the manufacturers driver and not the standard Microsoft RS-232 driver. Each device has a Header block (optional) that describes the device. What you see in the Device Manager is the Header information. You would have to enumerate through all devices and check type and header to find the device. See following : https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/enumerate-devices – jdweng Mar 23 '21 at 12:19
  • Where can I find the a Header block of the device? – user1245 Mar 23 '21 at 12:26
  • You don't directly. The driver loads the DeviceInformation and you get from the info using DeviceInformation.FindAllAsync() [or equivalent]. – jdweng Mar 23 '21 at 13:00
  • The following may be helpful: https://stackoverflow.com/questions/65957066/serial-to-usb-cable-from-a-scale-to-pc-some-values-are-just-question-marks/65971845#65971845 . – Tu deschizi eu inchid Mar 23 '21 at 15:22

0 Answers0