Android USB同步数据传输
我目前正在尝试找到一种方法来处理 Android 3.2 平板电脑(支持主机模式)上的同步端点上的 USB 数据传输。编写一些原型代码后,我注意到在 USB_ENDPOINT_XFER_ISOC 的常量文件中声明“同步端点类型(当前不支持)”。
这可以在不root设备的情况下实现吗?如果是这样,我该怎么做呢?
理想情况下,我希望留在 java API 中,但如果这只能通过 NDK 实现,我将不得不追求这一点。我还了解到,根据以下帖子,可能存在一些 USB 带宽问题: 从设备到主机的用户模式 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在Android(或Linux)下编写了一个用于USB同步数据传输的Java类: UsbIso< /a>
它使用 JNA 访问 USBFS 通过 IOCTL 的 API来电。
I have written a Java class for USB isochronous data transfer under Android (or Linux): UsbIso
It uses JNA to access the USBFS API via IOCTL calls.
我相信,你“可以”在没有 root 的情况下做到这一点。
您需要使用一些与使用 USBFS 的 USB 设备接口的本机 C 代码来完成这一切。最大的问题来自于缺乏linux的usbfs文档。基本上一切都必须通过 ioctl 来完成。也就是说,您确实可以像通常从 Java 中一样打开设备。然后,您将文件描述符从 USBDeviceConnection
添加到该文件您需要自己解析所有 USB 描述符。您可以再次从 USBDeviceConnection 获取它们。从一个描述符跳转到另一个描述符很简单,查找每个描述符含义的文档是一件令人头疼的事情,但您可以在 www.usb.org 上找到大部分文档。
我已经编写了解析音频设备所需的大部分代码,并且一直尝试提交同步传输,然后开始出现错误。
切换到 libusb 后,我发现问题就我而言,是因为音频设备也有 HID 控制器,而默认驱动程序附加到这些控制器并窃取了同步传输的所有带宽。如果我早点知道这一点,我可能会坚持使用非 root 非 libusb 方法。事实上,我确实通过 lib usb 进行了同步传输,但它需要一个 root 设备:(
在某些时候我会回到它。
总之,我很确定它是可能的,但它不会很容易!
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!!
您可以在我的 git hub 存储库上找到 UsbIso 64 位的可运行解决方案:
https: //github.com/Peter-St/Android-UVC-Camera/tree/master/app/src/main/java/humer/uvc_camera/UsbIso64
你需要全部UsbIso64 文件夹中的 5 个文件可以使用 USBIso,如下所示:
您可以将此版本的 UsbIso 与 32 位和 64 位设备一起使用。
到目前为止,
彼得
you can find a runnable Solution of the UsbIso 64 bit on my git hub repo:
https://github.com/Peter-St/Android-UVC-Camera/tree/master/app/src/main/java/humer/uvc_camera/UsbIso64
You need all 5 files of the UsbIso64 folder and can use the USBIso like following:
You can use this version of UsbIso with 32 and 64 bit devices.
So far,
Peter