Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android usb requestWait not return

ByteBuffer byteBuffer = ByteBuffer.allocate(9);;    
UsbRequest request = new UsbRequest();
request.initialize(mConnection,mEndpointIntr);
boolean b = request.queue(byteBuffer, 9);
Log.d(TAG, "start the request wait");
UsbRequest ur = mConnection.requestWait();

I want to use Android USB interrupt. The above code is a thread to receive data from my own USB board. But when I try to call UsbRequest ur = mConnection.requestWait(); the function does not return, it always runs into requestWait(). Why does this happen?

like image 449
user1728783 Avatar asked Oct 08 '12 12:10

user1728783


1 Answers

The requestWait() in your code will wait for the result of the request.queue(byteBuffer, 9)

Here are some possible reasons why it is not returning:

  1. Your request queue is on a different endpoint than what your USB device is actually sending data on. Double check that you are listening on the correct interface and endpoint.

  2. On the USB device firmware side, do not create your interrupt endpoint on common interface class such as HID. Create a new vendor specific interface, otherwise kernel may get hold of the interface if it is HID and request queue may fail, this is what happened to me.

like image 75
andrei Avatar answered Nov 08 '22 00:11

andrei