问题描述
我发现了几个关于这个主题的帖子,但是在阅读之后我对我的问题没有一个清晰的概念.
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 设备之间进行串行通信.(此时外接设备与其他非安卓设备使用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.
我们可以开发一个使用 USB 电缆与我们的外部设备通信的 android 应用程序吗?我的意思是,向设备发送数据和从设备接收数据,这两种方式,我们都希望将 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 的设备应该可以工作,但仍然是您应该进行的每台设备检查.我目前正在使用 Acer Iconia Tab A510,到目前为止它似乎可以工作,但有一些小故障:例如,您无法在使用 USB 端口时为设备充电,因为它与充电器共享但与 USB 不兼容.李>
- 正如 Neil 所说,USB API 是低级的,所以我认为您需要一个适用于您的 USB 芯片组的驱动程序(您身边的那个,即在您的设备中).我在这里非常幸运,因为有一个开源项目正在开发 FTDI 芯片组,而这恰好是我选择的.如果这也是你的情况,你应该检查项目:
- FTDriver:https://github.com/ksksue/FTDriver
- Android USB 串口监视器精简版:https://github.com/ksksue/Android-USB-Serial-Monitor-Lite 这个甚至在 Google Play 中有一个应用程序,所以你可以安装它并开始玩";-)
- 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".
干杯,阿西尔.
这篇关于Android:USB通信Android<->外接设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!