I have one custom made device for measuring current. This device can be connected to PC and communication is done over USB. It is based on FTDI chip. I have application written in Java and that application is using rxtxSerial.dll library and gnu.io.rxtx_2.1.7.4.jar. Now I want to port this application on my android device and I'm litte bit confused what to do that? All I have is android tablet (os version 4.1.1), OTG cable and this measuring device.
Should my device be rooted? Is there any kind of library that I can simply add to my Java Android application and read data over USB? Where to start?
I have tried to port existing application for PC using same library, but rxtxSerial.dll is missing and I can't transfer it to my android device.
I can really recommend the USB-Serial-For-Android library, it supports multiple popular usb-to-serial chips (also FTDI) and there is no rooting required. Check out the GitHub project here.
There is a project dedicated to serial communication on Android. android-serialport-api. I think, it is a good resource to start with.
FTDI also provides Android related resources.
I think there's currently only one properly maintained library for serial USB communication and it's felHR85/UsbSerial. It supports several USB chips including FTDI (see Devices Supported).
Unfortunately mik3y/usb-serial-for-android seems to be dead.
And no, you don't need to root your device for connecting to and communicating with a USB device.
EDIT: We have a maintained fork of mik3y's library. See kai-morich/usb-serial-for-android
EDIT2: It seems that all of these libraries are maintained again, mik3y joined forces with kai-morich and they are working together.
Related
I am in the planning stages of a project and potential issue has come up and I can't find the answer.
I am going to use a raspberry pi 4 with Android installed. To achieve my goal I will have to use a Bluetooth USB adapter with an external aerial. Because the raspberry and pi already has an onboard Bluetooth module, how will the OS cope with a second module being plugged in?
Can I disable the on board Bluetooth or force Android to use a particular module exclusively e.g the usb module?
Thanks
Unfortunately this is either not doable or at least not straight-forward. The reason is that the Android OS was designed to have one adapter only that does the Bluetooth functionality (as can be seen here and here). Even if you find a way to do it on the OS level, I would personally advice against it as there's very little resources on how that is done and you might soon find yourself stuck on another issue.
Is there a reason why you wouldn't use Linux and the BlueZ stack instead? There are many resources and examples on how to do this and with BlueZ and you should be able to use multiple adapters without an issue. If using Android is a must, then another recommendation is to use another MCU to connect to the Bluetooth dongle and do the translation from BT/USB and then have the Raspberry Pi connected to the external MCU over USB.
Below are a few links with people having a similar problem:-
How to use two Bluetooth adapters in Android
Are multiple Bluetooth adapters under Android possible
If the Android version doesn't matter, there's even AOSP BlueZ for Android.
I have one custom made device for measuring current. This device can be connected to PC and communication is done over USB. It is based on FTDI chip. I have application written in Java and that application is using rxtxSerial.dll library and gnu.io.rxtx_2.1.7.4.jar. Now I want to port this application on my android device and I'm litte bit confused what to do that? All I have is android tablet (os version 4.1.1), OTG cable and this measuring device.
Should my device be rooted? Is there any kind of library that I can simply add to my Java Android application and read data over USB? Where to start?
I have tried to port existing application for PC using same library, but rxtxSerial.dll is missing and I can't transfer it to my android device.
I can really recommend the USB-Serial-For-Android library, it supports multiple popular usb-to-serial chips (also FTDI) and there is no rooting required. Check out the GitHub project here.
There is a project dedicated to serial communication on Android. android-serialport-api. I think, it is a good resource to start with.
FTDI also provides Android related resources.
I think there's currently only one properly maintained library for serial USB communication and it's felHR85/UsbSerial. It supports several USB chips including FTDI (see Devices Supported).
Unfortunately mik3y/usb-serial-for-android seems to be dead.
And no, you don't need to root your device for connecting to and communicating with a USB device.
EDIT: We have a maintained fork of mik3y's library. See kai-morich/usb-serial-for-android
EDIT2: It seems that all of these libraries are maintained again, mik3y joined forces with kai-morich and they are working together.
I want to connect my Xbee module to my android phone and communicate with it by sending AT commands.
I do know of the USB host facility provided by Android phones, but I do not know how to send data to it.
I have the java-Xbee API and I am able to talk to the Xbee using my computer but since my project involves using the Android OS, any help on this topic will be appreciated.
According to this Google Code Page, the java-Xbee API requires Java >= 5 and RXTX. Considering those two requirements:-
RXTX on android is not an out of the box lib and may require some hacking which may or may not work.
I'm not a Java VM expert, but i know desktop OS JVMs work differently from Dalvik.How well would Dalvik run code developed for JVM? Here is a nice StackOverflow topic discussing the two.
Faced with the above challanges, are you brave enough to boldly go where no man has gone before?
Could you also consider the following well documented and supported approaches:-
Ytai Ben-Tsvi & Sparkfun's IOIO-OTG
Saves you the headache writing android 3.1+ USB host code and thus allows you to use cheaper phones that run droids 1.5 to 2.3 (without hacking the latter).
Digi's WiFi to Xbee
Allows you to link your android phone (or any other programmable wifi enabled computer) to your device over the internet.
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
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:
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.
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.
If you are using a serial device and have the ability to talk to it over native serial, you might want to consider IOIO (see http://ytai-mer.blogspot.com/2011/04/meet-ioio-io-for-android.html for more details).
I'm building an Android custom system. I did connect several devices on the USB. I looked to connect a device on the OTG port, the one that usually gets out of a tablet on which you use ADB. I gave up. This is a nightmare. I don't think you can use ADB on the OTG USB that is currently a device and expect to be able to use another device like a USB to serial converter. That means that you loose the whole ADB toolchain for debugging when you want to use the port as a host. On top of that, the USB OTG drivers you have for your tablet was probably not very well tested in host mode since it's not really used that way. So lots of headakes.
The simple way that I found was to use the second USB port on the CPU. This one is a plain HOST port (unfortunately limited to 12 Mbit/s). Unfortunately, I don't know if there are any tablet out there with 2 USB port available from outside (One OTG and one host).
If you get a set-up with two USB port (one HOST) then it's possible to compile as a module (drivername.ko), a usb to serial converter. There are several chipset supported in the kernel source tree and I already used a few of them and it works.
hope this bit of info is helpful.
I've got an application that is written in Java and which talks to a device using virtual serial port (ie a USB CDC ACM device). Currently it runs an a PC (Windows/Linux/Mac OS X),
but it would be a perfect match to be able to port this to a cheap tablet PC to create a stand alone system.
I've been googling for hours now and it seems quite a lot of people are interested in this sort of thin (no surprise there) and some have managed, but I've not found a good match for what I'm looking for or a good place to discuss this.
I'm looking at something like this:
http://www.prlog.org/10776061-101-inch-android-ipad-android-google-mid-tablet-pc.html
I would like to discuss the following:
This says that it supports USB host so it should be doable, eh?
Android is a kind of Linux so I should be able to use a serial dongle there, right?
Has Android got drivers so that I could just plug in a serial port dongle and open it as /dev/tty?
Would the above quoted APAD be usable as a development platform ?
So where would be a best place to discuss this?
br Kusti
To keep this at least partly programming-related: If your application has a GUI, moving to Android is not going to be a load-it-and-go effort. Android has a very different application structure that you're used to and doesn't have Swing (if that's what you're using) or any GUI toolkits other than its own.
On your USB problem: There is support for a few USB-to-RS232C adapters in the stock kernel, but there are a bunch of practical reasons not to use it. Most involve limiting yourself to devices that support host mode, cabling and powering the Android device and the serial adapter. You might be better off using a Bluetooth-to-RS232 adapter on your serial device, which would allow your app to run on a wider variety of devices and gets you the bonus feature of being wireless to put in your marketing material.
I just ported the RXTX library to the Android. Unfortunately I had to fork it to accomodate for different layout of the android projects. More details are here http://v-lad.org/projects/gnu.io.android/
You need to have a device that supports host USB mode. Also the kernel on the device has to support the USB to Serial converter or you have to recompile the kernel yourslef.