[Android Software/Hacking General [Developers Only]] meltwater:
RS232 on android

Topic Four: Low Level Interfacing

Part One: Android RS232 I/O

This is something which although I was very keen to have working on the tablet, I very much doubted I’d be able to have. However, I think I have got very lucky here and stumbled upon a solution which works for this tablet and for the USB-serial device I have (Prolific USB-RS232 dongle based on the PL-2303 USB-to-Serial Bridge Controller chip).

(Click Image For Larger Version)

Clearly I can not take any credit for this amazing feat, but I wish to share it. The source thread is from here on slatedroid - PL2303 & Other Usb To Serial Modules and is thanks to user eXell for some excellent work here.

Why RS232?:

Those of you not familar with RS232 and serial devices may wonder what use this connection is and how it can be useful. RS232 is an old standard which allowed basic communication and data transfer between computers and devices (essentially the forerunner to USB), the advantage is that it is a lot simpler to handle at a basic level so is very useful for hobbist programmers etc. I would expect for most people it won’t be useful at all, however for me it is!

RS232 is also commonly used for outputting debug data from embedded software tools and devices and thus it quite useful to have something which can easily connect and display the information. In addition to that, many devices can take RS232 commands and be controlled through this interface (such as power supplies etc), so having the ability to do this through Android could prove rather useful (the tablet providing a touch interface for example). Other uses could be to interface with RS232 Infra-red port so that not only could you (in theory) control the tablet using any remote control but you could also send out IR commands too.

What will you need:

Rooted Telechips Based tablet (the .ko file is compiled specifically for telechip devices apparently)

The USB-to-SERIAL.zip file (I’ve re-uploaded it here since there is no direct link, hopefully eXell won’t mind this) - this contains the compiled kernal module (pl2303.ko) and test application (SerialPort_0.7.apk).

adb setup on your host computer.

A USB-RS232 dongle (PL-2303 type - determine this by viewing the “Driver/Hardware Instance Ids” under Device Manger, properties of the device on the Details tab. You should see Pid_2303 contained therein)

RS232 Data source - this can be hyper-terminal or similar.

Suitable cables to connect the USB-RS232 dongle to your device and to your RS232 data source.

A bit of luck!

Identify the drivers!

ark3116.ko - Arkmicrochips ark3116 chipset RS232 to USB device

cp2101.ko - Silicon Labs CP2101 chipset RS232 to USB device

ftdi_sio.ko

pl2303.ko - The Prolific PL2303 chipset RS232 to USB device I used before.

Install the test console program:

Copy over the SerialPort_0.7.apk file and install it.

(Click Image For Larger Version)

Note:

The source for this program is available here on Google Code - thanks to cedric.p, which makes this particularly useful since it provides a basis for programming custom functionallity.

Install the driver:

Connect the device to your host computer and connect adb.

Use adb to put the .ko file somewhere accessible (i.e. on the sdcard) or copy it manually if you wish.

adb remount
adb push pl2303.ko /sdcard/pl2303.ko

Open a shell interface on the device and install the driver:

adb shell
insmod /sdcard/pl2303.ko

Hopefully you won’t get an error at this point, if you try to do it a second time you will get the following (so you know it is definitely installed):

insmod: init_module '/sdcard/pl2303.ko' failed (File exists)

Test the RS232 link:

Attach the USB-RS232 dongle to your device and to the data source.

Load up the Serial Port application.

(Click Image For Larger Version)

Within the setup page, select "ttyUSB0 (usbserial)" and a Baud Rate to match your source.

Note:

It seems like Flight mode may block the USB device from being enabled, so if it is not present ensure Flight mode is off or try reinstalling the drivers.

Switching to the console, ensure you accept the superuser request, you should then observe your RS232 data source!

(Click Image For Larger Version)

When you run this application you will need to be able to grant it Super User permissions, hence the need to have rooted your tablet previously (clearly in order to access the low-level hardware, the extra permissions are required).

Other devices?:

Unfortunately I’ve mis-placed my USB-Bluetooth dongle at the moment (probably on account of being about the size of a tiny usb plug). Hopefully when/if I find it I shall experiment with the Bluetooth drivers too and see what, if anything, I can get to work.

UPDATE: Found the little BT-USB thingy!

UPDATE 31/10/2011:

Drivers for android are very specific, so they usually have to be compiled for the particular tablet or phone they will be used on and also for the particular kernel the rom uses. However, the basics of installing a driver will be the same once you have a suitable .ko file (kernel object) which matches your configuration. When I get a larger set of drivers and devices which work with my tablet etc I'll try to post some information about getting them working if people are interested.