Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to communicate with a USB device from Android tablet?

Tags:

android

usb

From a year ago, Is there a way to communicate with USB devices on Android? this didn't look like a common requirement, but tablets have evolved, and hopefully, the OS has, as well.
I need to operate a simple USB relay card from my Curtis LT8025 tablet, currently running 2.1 patched.
I'm also a newcomer to both Android and java, so relatively clueless!
No need for bi-directional communication, just a simple serial command out to the device.

Any suggestions?

Thanks!
Dave

like image 424
DBell Avatar asked Oct 12 '22 02:10

DBell


1 Answers

Sadly, there is currently no standard API to achieve wired communication with Android devices. I was facing a similar issue a while back (see Android: Communicating with a USB device which acts as host ).

I was able to successfully implement the solution provided by CommonsWare. Leave a comment if you need more help regarding this and I can provide details.

  • Edit (more details) -

Basically, I narrowed down to two possible solutions for this problem:

  1. Modify the Android source itself to include custom drivers for whatever purpose you need and install this in your tablet. Since its mostly based on Linux, if you develop the drivers for Linux, the same can be used in Android with a little modification. This solution is simpler to develop, but not practical commercially if you are not providing the tablet/phone yourself.

  2. Make your USB device act as an host and implement the ADB driver/command-set in your device. When connected, you can issue "adb forward" to forward tcp ports so you can interact with your Android apps and have two way communication between the device and the app.

I used the second method and it works flawlessly. But its only practical if you are making USB host devices. for USB slaves, first method is the only way I recon.

like image 84
Vaayu Avatar answered Oct 21 '22 07:10

Vaayu