I am about to start a new project that works with a USB HID device. I know to send a command to a HID device, you use the following method:
controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout);
While I am pretty sure what requestType
, buffer
, length
, and timeout
are, I don't clearly understand request
, value
, and index
. What do these arguments do and what would I pass to send the my commands?
For example, if I were to set speed on a treadmill that has a specified command to set speed, what would I pass? The documentation I got was not clear about this.
Request, Value and Index can be found from USB specification. These are standard parameters for control pipe commands.
From USB spec 3.0 Section 9.3 -
Following is the table for the values corresponding to Request, Value and Index from USB spec -