Android USB requestWait不返回 [英] 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();
我想使用Android USB中断.上面的代码是一个线程,用于从我自己的USB板接收数据.但是,当我尝试调用 UsbRequest ur = mConnection.requestWait();
时,该函数不会返回,它始终会运行在 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?
推荐答案
代码中的 requestWait()
将等待 request.queue(byteBuffer,9)
以下是它不返回的一些可能原因:
Here are some possible reasons why it is not returning:
-
您的请求队列与USB设备实际在其上发送数据的端点不在同一个端点上.仔细检查您是否在正确的接口和端点上进行监听.
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.
在USB设备固件方面,请勿在常见接口类(例如HID)上创建中断端点.创建一个新的特定于供应商的接口,否则,如果该接口是HID,则内核可能会占有该接口,并且请求队列可能会失败,这就是我所发生的事情.
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.
这篇关于Android USB requestWait不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!