How to control a serial device on Android?

Kate G picture Kate G · Jul 21, 2011 · Viewed 34.3k times · Source

I want to develop an application whitch control the serial device over usb, on Linux Android.
An Android OS is 3.1 that supports USB host.

Q1: Please let me know how to get which port the serial device is mounted .

I got likely USB device information when I got "Dump Device State" on Dalvik Debug Monitor.
And, I checked /dev/tty* on android device by using adb.
I don't know which one(/dev/tty??) the serial device is.

adb shell
$ ls /dev/tty*
/dev/tty
/dev/ttyFIQ0
/dev/ttyHS0
/dev/ttyHS2
/dev/ttyHS3
/dev/ttyHS4
/dev/ttyS0
/dev/ttyS1
/dev/ttyS2
/dev/ttyS3

Q2: Please let me know how to control the serial device on Android without root permission.

I have a application(exe) that can control the serial device on linux.
I tried to do on android , but I couldn't do for permission denied.

And, I tried redirect to the serial port(maybe)
$ ls > /dev/ttyS0
But I couldn't.
cannot create /dev/ttyS0: permission denied.

Please let me know anything how to control and access to the serial device.

Answer

not2qubit picture not2qubit · Jan 31, 2012

There is a great review of this in the XDA forum thread:

How to talk to the Modem with AT commands.

That thread show you how to send AT commands (ATC) with a remote terminal (USB connected to you PC), but it has not yet solved the problem of how to use a local (phone) terminal to talk to the phone Modem.

BTW. You need a terminal application/program to do any talking to the modem (remember, its a 2-way communication). So that's why you need a rooted device, since the root kit usually come with Busybox (that includes a microcom terminal program). Otherwise you have to write your own program.