安卓:USB通讯的Android< - >外部设备
我发现speacking有关此主题的多个线程,但在阅读他们,我没有关于我的问题一个清晰的概念。
I found several threads speacking about this subject, but after read them I don't have a clear idea about my problem.
我们有一个外部设备(像一个TomTom设备,我的意思是,没有一个配件),我们希望这个设备连接到Android设备。我们希望有外部设备,并使用USB连接Android设备之间的串行通信。 (在这个时候,我们有外部设备和其他非Android设备之间的通信采用RS232接口,但外部设备可以使用USB电缆处理通信)
We have a external device (something like a tomtom device, I mean, not an accessory) and we want to connect this device to an android device. And we want to have serial communication between the external device and the android device using a USB connection. (At this time we have communication between the external device and other non android devices using RS232 interface, but the external device can handle the communication using a usb cable)
当我读到,我们自3.1 USB API的支持。
As I read, we have USB API support since 3.1.
我们能开发一个Android应用程序这跟我们使用USB电缆外部设备进行通信?我的意思是,将数据发送到设备,从设备接收数据,这两个方面,我们要使用的Android设备作为一个摆设。
Can we develop an android application which communicates with our external device using USB cable? I mean, sending data to the device and receiving data from the device, both ways, we want to use the Android device as a "display".
非常感谢你提前。
我基本上做你所描述的一样。我还处于初期阶段,但我已经成功下的一些限制,例如通讯:
I'm basically doing the same you are describing. I'm still at the early stages but I've managed such communication under some constraints:
- 您需要支持USB主机API的设备。 API本身由于Android 3.2左右已经出现,但不是每个设备似乎支持它。它看起来像极了设备运行> 4.0应该工作,但仍然是一个每个设备的检查,你应该做的。我目前使用的是宏碁ICONIA TAB A510,迄今似乎工作,但有一些小问题:例如,你不能在设备,而使用USB端口,因为它是与充电器共用,但与USB不兼容充电。 LI>
- 当尼尔说,USB API是低级别的,所以我认为你需要为你的USB芯片(一个在你身边,也就是说,在您的设备)的驱动程序。我一直很幸运,这里有一个开源项目工作的FTDI芯片组恰好是那些我选择。如果这是你的情况也一样,你应该检查的项目:
- FTDriver: https://github.com/ksksue/FTDriver
- 在Android的USB串行监视器精简版:https://github.com/ksksue/Android-USB-Serial-Monitor-Lite这一次甚至在谷歌的应用程序播放,所以你可以安装它,并开始玩; - )
- You need a device supporting the USB Host API. The API itself has been around since Android 3.2 or so, but not every device seems to support it. It looks like most of the devices running >4.0 should work, but still is a per device check you should do. I'm currently using an Acer Iconia Tab A510, which so far seems to work but has some glitches: for instance, you cannot charge the device while using the USB port as it is shared with the charger but not compatible with USB.
- As Neil says the USB API is low level, so I think you will need a driver for your USB chipset (the one at your side, i.e. in your device). I've been quite lucky here as there's an open source project working on FTDI chipsets that happen to be the ones I've chosen. If that's your case too, you should check the projects:
- FTDriver: https://github.com/ksksue/FTDriver
- Android USB Serial Monitor Lite: https://github.com/ksksue/Android-USB-Serial-Monitor-Lite This one has even an app in Google Play, so you can install it and start "playing" ;-)
我希望这有助于。正如我所说的,我开始在这个生态系统中工作,我还是要发现身边很多地方我的路。
I hope this helps. As I've said, I'm starting to work in this ecosystem and I still have to find my way around many "places".
干杯, Asier。