-
Notifications
You must be signed in to change notification settings - Fork 149
Description
EDITED (2024-01-06): updated 2. Improvement request topic about a workaround using the winapi crate.
EDITED (2024-01-01): updated 2. Improvement request topic about a workaround using the windows crate.
1. Issue description
On POSIX systems, the UsbPortInfo returns custom Manufacturer and Product name linked to iVendor and iProduct attributes from Device Descriptor. In contrast, in Windows:
- the Manufacturer name is obtained from the DEVPKEY_Device_Manufacturer property key; and
- the Product name is obtained from the DEVPKEY_Device_FriendlyName property key.
This is causing the following issue:
- The Manufacturer and Product name information obtained from Windows is completely different from POSIX. If this information is used for device detection, the code will not be portable.
2. Improvement request
In Windows, the information must be obtained via DeviceIoControl. In a similar way to the lswinusb – a Rust library for listing USB Descriptors on Windows.
Workaround
This is a workaround that was developed using the lswinsub project, but using the winapi crate instead of the windows or windows-sys crate:
It can be tested using the iocontrol feature. Example:
cargo run --features iocontrol --example list_ports
But it is not a solution developed by someone who has experience with Rust and the Win32 API. This needs to be reviewed and/ or rewritten by someone with more experience.
3. Others
Additional information:
- The USBViewer program also uses DeviceIoControl:
- Python module pySerial also faces the same problem: