Skip to content

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

@jcsxdev

Description

@jcsxdev

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions