Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: USB Communication Android <-> External Device

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.

like image 481
Kosmo Avatar asked Oct 04 '12 09:10

Kosmo


People also ask

How do I get USB permissions on Android?

When you connect USB the first time (with already installed app), system call permission dialog. Then another time at start app usb will get permission automatically.

How do I change USB settings on Android?

To change USB preferencesDrag down the status bar, and then tap Android System next to (USB icon). Tap Tap for more options, and then select an option.

What is USB accessory mode?

USB accessory mode allows users to connect USB host hardware specifically designed for Android-powered devices. The accessories must adhere to the Android accessory protocol outlined in the Android Accessory Development Kit documentation.


1 Answers

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

Cheers, Asier.

like image 102
Asier Avatar answered Nov 15 '22 04:11

Asier