11
votes

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.

3
To do this utilizing the Android USB host capability and its corresponding API, You must implement the USB-serial driver code in userspace within your Application. No kernel "serial" driver or device ends up being involved.Chris Stratton
Which serial device? There can be hundreds! Please specify what exactly you want to do.not2qubit

3 Answers

4
votes

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.

4
votes

in next step, you can test tty* port by couple of command: $ cat /dev/tty* /for receive the characters from tty and $ echo 'text string' > /dev/tty* /for send characters to tty

good luck!

0
votes

Try on a rooted device?? In researching the same thing I've read that only a few 3.1 / 2.3.4 devices allow non-root access to the usb port.

This is what I get on my HTC Desire unrooted, 2.2:

$ ls /dev/tty*
ls /dev/tty*
/dev/tty
/dev/ttyHS0
/dev/ttyHSUSB0
/dev/ttyHSUSB1
/dev/ttyHSUSB2
/dev/ttyMSM0

My Asus Transformer, unrooted, 3.2:

$ ls /dev/tty*
ls /dev/tty*
/dev/tty
/dev/ttyHS1
/dev/ttyHS2
/dev/ttyS0
/dev/ttyS1
/dev/ttyS2
/dev/ttyS3

I get exactly the same list when docked with the Keyboard Dock installed (It as 2 x USB ports).

Hope it helps, please let me know I'd love to be able to do the same.