elixir-circuits / circuits_uart

Discover and use UARTs and serial ports in Elixir
Apache License 2.0
189 stars 48 forks source link

Incorrect manufacturer reported in Windows 10 #65

Open sparta-developers opened 5 years ago

sparta-developers commented 5 years ago

Setup

Expected Behavior

We're running into an issue where on OSX, our USB devices show up in Circuits.UART.enumerate() with the actual device manufacturers, with serial numbers. We would expect the same behavior in Windows.

Actual Behavior

In Windows, the manufacturer key is coming up as (we think) the manufacturer of the device driver. For example, for one type of device, in Windows the manufacturer is "Microsoft," whereas the other device appears as "FTDi". When we look at the COM ports in usbview.exe, we see the correct manufacturer values listed under the iManufacturer key, with the serial number listed as iSerialNumber.

It looks as if the values provided by the <setupapi.h> header may be specific to the device driver, rather than the usb device information. In we see definitions for the values provided by USB.

The source code for usbview.exe shows an example for how to retrieve this information from USB.

Since UART is not just USB-specific, we weren't sure if making the change to get this info from the USB bus would be something that should or should not be added to this library. We spent a bit of time trying to get this data using more recent (Vista+) functions available from setupapi, but haven't yet found a way to do so. If you know how to do so and are ok with this change, we're happy to submit a pull request.

Thanks!

fhunleth commented 5 years ago

Hmm. It has been so long since I've used Windows regularly that I'm really not sure with doing some digging.

There might be hints in Node Serialport - https://github.com/serialport/node-serialport/blob/master/packages/bindings/src/serialport_win.cpp#L782 or Qt - https://code.qt.io/cgit/qt/qtserialport.git/tree/src/serialport/qserialportinfo_win.cpp#n323.

I only very briefly skimmed them since I can't look at this now.