5
votes

I found several threads speacking about this subject, but after read them I don't have a clear idea about my problem.

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)

As I read, we have USB API support since 3.1.

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".

Thank you very much in advance.

3
I also having the same requirement. we need to send the data to the usb port and cable and external device will get it. From this point external device will process itself.Is it possible to send data to external device without drivers and libraries from the application? Please help.Krishna Prasad

3 Answers

12
votes

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:

  1. 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.
  2. 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:

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".

Cheers, Asier.

1
votes

Currently the adb interface is one way. Flow is controlled by the host PC using adb. Looking at your requirement, looks like you might need to open up the source code, re-tune the USB driver to allow communication both ways. After that, you will need to design your very own API that allows an application to send messages via USB. This will require a lot of work as the current Android model does not support it.

0
votes

If the android device that you are attaching your device to, supports host mode then the usb api can help. it is however a low level api that talks in usb request buffers (URBs) I am writing a serial abstraction at the moment using this api but it is not ready for airing at present.

If your non android device is able to act as host then as Royston suggests the adb route might be best for you and there are examples of how to do this in the api bundles post api version 12.