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

How can I send this hex value package to the device? #77

Closed athusrv closed 4 years ago

athusrv commented 5 years ago

I'm trying to communicate with a hid device. The command that I want to send is this array:

[0x80, 0x06, 0x03, 0x03, 0x51, 0x31, 0x00, 0x27]

However, the value 0x80 is out the range of the byte type.

How can I send this array to the device?

This is the code I'm trying to execute:

byte message[] = new byte[] {0x80, 0x06, 0x03, 0x03, 0x51, 0x31, 0x00, 0x27};
int length = device.write(message, message.length, (byte) 0x00);
gary-rowe commented 4 years ago

Apologies for the slow response. You might have to represent the 0x80 value as follows:

[(byte)0x80, 0x06, 0x03, 0x03, 0x51, 0x31, 0x00, 0x27]

Given that this is an old support request, I'll close it now.