hidapi
hidapi copied to clipboard
Cannot iterate through multiple devices of the same vendor and product ID.
Hello,
I am not able to use the serial number to identify a specific device connected to my computer, is this feature working?
Regards,
Yes it is working.
Huh? Okay, must be something wrong with how it is stored. Is there another way I could easily select one of up to 6 individual usb devices all connected at the same time and sharing vendor and product ids?
Yes it is working.
Worth noting, there seems to be a bug in Windows where the serial number is returned as ?????
.
I have tried several HID libraries to no avail.
This issue is somewhat mentioned here: https://github.com/nyholku/purejavahidapi/issues/35
In response to my previous message... the Windows serial number with question marks is specific to certain hardware, such as Mettler Toledo weight scales. This doesn't occur for all HID hardware.
In regards to the original issue... @Hobbyistpython... if you're using Linux, for serial numbers to work as non-root a slight udev
modification is needed as somewhat explained here, but without clear instructions for how to resolve it... #118.
The solution's in the source code here: https://github.com/signal11/hidapi/blob/master/udev/99-hid.rules
Sample udev
rule:
libusb
# HIDAPI/libusb
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
# ... or for ALL devices...
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"
hidraw
# HIDAPI/hidraw
KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
This is a plain text file which can be placed (for example): /lib/udev/rules.d/99-udev-override.rules
.