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

negative shorts #74

Closed jonbanjo closed 4 years ago

jonbanjo commented 5 years ago

You’ve probably got these anyway if you are working on a new version but a couple of observations found while playing with a usb logging multimeter which has a product id of e008.

HidDevice.toString() prepends “ffff” to the product id. HidDevice.isVidPidSerial() does not compare the int parameters with the device short product id correctly.

I’d guess there may be a couple of others where the short representation is negative but the library worked well otherwise for my brief experiment.

gary-rowe commented 5 years ago

Thanks for bringing this to my attention. It may be a while before I can get around to fixing it.

gary-rowe commented 4 years ago

Hi. It's been a long while, but I have managed to get around to this.

Can I verify that your concern with the short comparison is the unsigned upcast? For example a structure similar to this:

int intVendorId == shortVendorId & 0xFFFF;

See https://github.com/gary-rowe/hid4java/blob/29a20a0484e3f2faa09935d4cb73c5536ed2d8a6/src/main/java/org/hid4java/HidDevice.java#L402

gary-rowe commented 4 years ago

Closing as this is essentially a duplicate of #65