Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: UsbPortInfo: Provide the same info about Manufacturer and Product name as POSIX #146

Open
jcsxdev opened this issue Dec 27, 2023 · 2 comments · May be fixed by #152
Open

windows: UsbPortInfo: Provide the same info about Manufacturer and Product name as POSIX #146

jcsxdev opened this issue Dec 27, 2023 · 2 comments · May be fixed by #152

Comments

@jcsxdev
Copy link

jcsxdev commented Dec 27, 2023

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
  2. Improvement request
  3. Others

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:

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:

  1. The USBViewer program also uses DeviceIoControl:
  2. Python module pySerial also faces the same problem:
@sirhcel
Copy link
Contributor

sirhcel commented Jan 12, 2024

You are absolutely right. I would expect to get the same information on systems where the port enumeration returns anything at all.

Than you very much for pointing this out and your comprehensive research! My schedule is tight these days. But it looks like you are already working on implementing this and this looks good skimming through it. Awesome! :) Would you mind filing a PR when this works for you?

@jcsxdev
Copy link
Author

jcsxdev commented Jan 15, 2024

Than you very much for pointing this out and your comprehensive research! My schedule is tight these days. But it looks like you are already working on implementing this and this looks good skimming through it. Awesome! :)

Thank you for the feedback.

Would you mind filing a PR when this works for you?

No problem. I will file a PR when I complete some tests.

Example:

  • The tests I had performed worked under the following condition:

IMG01_CONDITION1

  • But they failed under the following condition:

IMG02_CONDITION2

I have made new changes to the iocontrol feature to fix this issue, but they haven't been tested yet.

@jcsxdev jcsxdev linked a pull request Jan 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants