Android USB等时数据传输 [英] Android USB isochronous data transfer

查看:135
本文介绍了Android USB等时数据传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试寻找一种方法来处理我的Android 3.2平板电脑(支持主机模式)上的同步端点上的USB数据传输.在编写了一些原型代码之后,我注意到在USB_ENDPOINT_XFER_ISOC的常量文件中指出同步端点类型(当前不支持)".

是否可以在不生根设备的情况下实现?如果是这样,我将如何去做?

理想情况下,我希望保留在Java API中,但是如果只能通过NDK做到这一点,那么我将不得不这样做.我还了解,根据以下信息,可能存在一些USB带宽问题:解决方案

我相信,您可以"在没有root的情况下做到这一点.

您将需要使用一些本机C代码与使用USBFS的USB设备接口来完成所有操作.最大的问题来自缺乏Linux的usbfs文档.基本上,所有事情都必须通过ioctl完成.也就是说,您确实像通常从Java中那样打开设备.然后,您从 USBDeviceConnection

此外,您需要自己解析所有USB描述符.您可以再次从 USBDeviceConnection 获取它们.从描述符到描述符的跳转很容易找到每个描述符所表示的令人头疼的文档,但是您可以在www.usb.org上找到大多数文档.

我已经编写了对音频设备进行解析所需的大部分代码,并且一路尝试提交同步传输,然后开始出现错误.

在切换到libusb之后,我发现问题是因为音频设备还具有HID控制器,并且默认驱动程序正在匹配这些控制器,并从同步传输中窃取了所有带宽.如果我较早知道这一点,我可能会坚持使用非根非libusb方法.因为确实通过lib usb获得了同步传输,但它需要一个有根设备:(

在某个时候,我会回到它.

总而言之,我很确定它是可能的,但绝非易事!

I am currently trying to find a way to handle USB data transfer on an isochronous endpoint on my Android 3.2 tablet (Host Mode supported). After writing some prototype code, I noticed that in the constants file for USB_ENDPOINT_XFER_ISOC states that "Isochronous endpoint type (currently not supported)".

Is this possible without rooting the device? If so how would I go about doing this?

Ideally I was hoping to stay within the java API, but if this is possible only via the NDK I would have to pursue that instead. I also understand that there might be some USB bandwidth issues based on the following post: User mode USB isochronous transfer from device-to-host

解决方案

You "can" do it without root, I believe.

You'll need to do it all using some native C code interfacing with the USB device using USBFS. The big issue comes from the lack of documentation of linux's usbfs. Basically everything has to be done through ioctls. That said you do open a device as you would normally from Java. Then you pass the file descriptor from the USBDeviceConnection

Add to that you will need to parse all the USB descriptors yourself. You can get at them, again from the USBDeviceConnection. Jumping from descriptor to descriptor is simple finding the documentation for what each descriptor means is a MASSIVE headache but you can find most of the documentation on www.usb.org.

I've written most of the code that is required to do the parsing for audio devices and I got all the way up to trying to submit an isochronous transfer and then started getting errors.

After switching to libusb I discovered that the problem, in my case, was because the audio device also had HID controllers and the default driver was atatching to those and stealing all the bandwidth away from the isochronous transfer. Had I known this earlier I might have persevered with the non-root non-libusb method. As it was I did get isochronous transfers working through lib usb but it required a rooted device :(

At some point I'll go back to it.

In summary, I'm pretty sure its possible but its not gonna be easy!!

这篇关于Android USB等时数据传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆