大佬教程收集整理的这篇文章主要介绍了Android usb主机:异步中断传输,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>发送带有endpoint_OUT的ByteBuffer
>在endpoint_IN上收到devic的消息
均处于中断模式.
非常感谢您的支持.
哈迪
一个漂亮的noddy请求 – >回复的代码看起来像这样.你会想要构建不同的实际代码,但这给你需要发生什么的要点(我希望)
public void run() { int bufferMaxLength=mEndpointOut.getMaxPacketSize(); ByteBuffer buffer = ByteBuffer.allocate(bufferMaxLength); Usbrequest request = new Usbrequest(); // create an URB request.initialize(mConnection,mEndpointOut); buffer.put(/* your payload here */; // queue the outbound request Boolean retval = request.queue(buffer,1); if (mConnection.requestWait() == request) { // wait for confirmation (request was sent) Usbrequest inrequest = new Usbrequest(); // URB for the incoming data inrequest.initialize(mConnection,mEndpoinTin); // the direction is Dictated by this initialisation to the incoming endpoint. if(inrequest.queue(buffer,bufferMaxLength) == truE){ mConnection.requestWait(); // wait for this request to be completed // at this point buffer contains the data received } } }
如果您实际上正在寻找一种以异步方式运行此IO的方式,而不会将线程绑定到其上,那么我认为您需要考虑使用DeviceConnection.getFilehandle()方法来返回一个标准文件句柄,理论上可以这样处理使用它就像是任何其他文件类型的资源.不过我会注意到我没有尝试过.
以上是大佬教程为你收集整理的Android usb主机:异步中断传输全部内容,希望文章能够帮你解决Android usb主机:异步中断传输所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。