12

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.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Kate G
  • 121
  • 1
  • 1
  • 4
  • 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 Jun 13 '14 at 16:57
  • Which serial device? There can be hundreds! Please specify what exactly you want to do. – not2qubit Jun 17 '14 at 21:24

3 Answers3

4

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!

datuan2008
  • 61
  • 1
4

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.

not2qubit
  • 14,531
  • 8
  • 95
  • 135
0

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.

Hein du Plessis
  • 3,305
  • 6
  • 34
  • 51
  • These all presume the presence of a kernel driver, which you are very unlikely to have unless the device is rooted (not the case here) or there's already a driver in the installation (unlikely unless the device is not an ordinary phone/tablet). The proper answer is to implement the USB-serial logic in userspace against the Android USB host API. – Chris Stratton Jun 13 '14 at 16:56
  • @ChrisStratton But while connecting through USB Host API and connected with windows PC , does not get USB device object . – Chetan Joshi Apr 19 '21 at 06:34