Skip to content

how to get HID usb port information #250

Closed

Description

@nxpfrankli

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

Activity

  1. Youw commented on Mar 10, 2021

    @Youw
    Member

    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.

  2. nxpfrankli commented on Mar 10, 2021

    @nxpfrankli
    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.

  3. Youw commented on Mar 10, 2021

    @Youw
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionInformation is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions