简体   繁体   中英

How are USB-HID devices handled that have no outgoing endpoints?

I've been working on a USB-HID Java for Android plugin that needs to communicate with a number of devices, and I've been mostly successful using the bulkTransfer() method.

Right up until I encountered a hardware device that didn't have any outgoing endpoints. This specific one had 2 interfaces and 1 endpoint on each one. Both were incoming, so it was not possible to send commands to it using bulkTransfer().

My questions:

1) Is it possible send the same commands to the device using the controlTransfer() method instead?

2) Can I use the same byte array I was passing in to bulkTransfer()?

3) If both of the above are true, what does the value and index parameters do on the controlTransfer():

https://developer.android.com/reference/android/hardware/usb/UsbDeviceConnection.html#controlTransfer(int,%2520int,%2520int,%2520int,%2520byte%5B%5D,%2520int,%2520int)

I looked at: how is different between controlTransfer and bulkTransfer?

But it didn't really answer my main question.

First as a note, HID's tend to use interrupt IN rather than bulk transfers. This is NOT the same thing as the control pipe or a bulk pipe. When you move a mouse or a keyboard (typically) it'll will send an interrupt message to your computer so the OS doesn't have to constantly poll the control pipe for reports. In android, this is done with queue / requestWait .

I've personally never seen an HID with a bulk pipe.

All devices have endpoint 0 which is a bidirectional control pipe. If you control the device's firmware, you could send custom commands on the control pipe. So in theory, you could do that and use the same byte array. But you need to know what your device is expecting in terms of request id, index and value. Index would likely be 0 (interface descriptor; UsbInterface.getId ). Value also depends on what your device is expecting (try 0).

For reference, here's the HID spec.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM