Android and Serial Port.
This is an informational page for my port of the RXTX library to the android platform. The RXTX library started as an implementation of Sun's JavaCOMM API and now it grew into an independent project. The main page for RXTX project is here.
Unfortunately the Android Java environment and the Linux environment are different enough from the standard Linux or Windows enironment that the library could not be used as is. So I made the port of the library. The current port is based on the GNU.IO library version 2.1.7.
Here is a picture of the test program running on the Motorola Droid connected via serial port to the embedded device running FreeNAS.
This library was tested in the following environment.
|USB-to-Serial port adapter||Silicon Laboratories CP-2103|
How to try it for yourself
Following the steps below will void your phone warranty. Also if you are not very careful you might end up breaking your phone. You have been warned, proceed with caution.
Obviously, you'll need an Android device either with built-in serial port or USB port that could switch to a host mode. Some devices such as Motorola Droid require a special dongle to switch the USB port to the host mode. More information about such dongles could be found here:
USB to serial port adapter. I used the Silicon Laboratories CP2103 evaluation kit which is available from DigiKey.
If you are not lucky to have the kernel on your device that supports the serial port you have to build one yourself. I have provided a pre-built kernel and modules for Motorolla Droid running Cyanogen 6.1. You can download it from the links below. Make sure you download both the kernel and the modules.
Rooting the phone and installing CyanogenMod
Because the standard Droid phone come with the serial driver, the phone has to be rooted. For myself when working with embedded android project I use the excellent CyanogenMod distribution. It gives all the features of a commercial Android platform plus many tools that come very handy for embedded work. This distribution is also very flexible to allow creating of locked down solutions to be deployed in the field. Look here for instructions on how to set it up. Note that the library was tested with version 6.1. If you install some other version the binaries (kernel and driver modules ) below might not work properly.
- Place the shared library to the /system/lib folder
- Create the properties file named gnu.io.rxtx.properties in /system/etc/ directory. The properties file has to contain the following text.
- Install an example APK either or download the source and build it yourself. To build the application check out this repository from the github. Then import both GNUIO and GNUITest projects into your eclipse environment and simply build it. Note that the application does not include the native library you have to either build one yourself or download one from below.
If you have questions comments suggestions regarding this library you can post them here or you can write me an email to tutorials AT v-lad.org.