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

how to get HID usb port information #250

Closed
nxpfrankli opened this issue Mar 10, 2021 · 3 comments
Closed

how to get HID usb port information #250

nxpfrankli opened this issue Mar 10, 2021 · 3 comments
Labels
question Information is requested

Comments

@nxpfrankli
Copy link

we have two board A and B connected to one PC, with the same chip, the same vid and pid, no serial number info.

How to get usb port information for each board?

libusb/libusb#885

@Youw
Copy link
Member

Youw commented Mar 10, 2021

There is no "official" way. You're expected to use fields of hid_device_info do distinguish your devices (all, but path), and serial_number is primary for this purpose.

Unofficial way: if you know exactly the version of hidapi library you use (and not relying on a system-installed instance), you may try to parse the path. See https://github.com/libusb/hidapi/blob/master/libusb/hid.c#L487
But I strongly do not recommend doing so, if you could use serial_numbers instead.
path is platform/backend - specific, and it won't work, for instance, if you choose to switch from libusb to hidraw backend.

Also, see #117.

@nxpfrankli
Copy link
Author

Our ROM have not provided serial_number info.

Our software work well with libusb at windows and linux.
we need a better solution cross windows, linux and macos.

@Youw
Copy link
Member

Youw commented Mar 10, 2021

If you need a reliable cross-platform solution - update your ROM to provide a serial_number.
Using path is not reliable nor easy to implement.

I cannot suggest you anything else.

If you wan't to continue a discussion, please use https://github.com/libusb/hidapi/discussions/categories/q-a instead.

@Youw Youw closed this as completed Mar 10, 2021
@mcuee mcuee added the question Information is requested label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Information is requested
Projects
None yet
Development

No branches or pull requests

3 participants