gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
229 stars 71 forks source link

Multiple devices with the same vid and pid #10

Closed mmatloka closed 7 years ago

mmatloka commented 9 years ago

Hi, Thx for making this library, I have encountered a few issues with usb4java ;) I have a question - there can be attached multiple devices with the same vid and pid. How then hidServices.getHidDevice will react?

gary-rowe commented 9 years ago

Sorry for the delay, just seen this message.

I've not tested this scenario, and would rely on the behaviour of the underlying hidapi library. If you are able to construct this as a test case I would be interested in the result.

gary-rowe commented 9 years ago

Any update on this?

mmatloka commented 9 years ago

Finally I was not able to test such scenario.

gary-rowe commented 9 years ago

OK. Thanks for the update. I might be in a position to test this myself now, so I'll leave this open to remind me.

gary-rowe commented 8 years ago

Finally got around to testing this. Here are my observations:

Overall it appears capable of supporting them but this would require comprehensive testing in a production environment to be certain.

Ready for review and close.

andyrozman commented 7 years ago

Reviewed. Looks ok.

gary-rowe commented 7 years ago

Merged and closed.

Laivindur commented 3 years ago

What if the serialNumber is also the same for both devices? So far I know, device SN may or may not be unique. We are working with a vendor which produces devices for vets. We have 2 units of the same device for testing and development purposes and at some point, we realized that both devices had the same vid, pid and iSerial. Don't know if this is normal or we just stumbled upon a mediocre vendor.

The only different serial number we get is the one we get when we address some request to the device and it does respond with the serial number defined by software which is totally different from the one we get from the hardware.

Is there any other device attribute candidate to be UID?

gary-rowe commented 3 years ago

In USB HID there are three main string descriptors: product, manufacturer and serial. At a low level the iSerial value is the index on to a device string which contains the actual serial number. However this index is dereferenced by Hidapi into the actual device string so whatever hid4java is returning is the actual serial string within the device.

Attempting to dig further with, say, getIndexedString() will fail (return code -1) as it isn't fully implemented within hidapi (seems to be a TODO item for quite some time).