Device Names on Android

Hi,

I have a program that logs serial port data. In order to do so it requires the full device name in linux (e.g. /dev/ttyUSB0) and a baudrate.

Does anyone know how I can find out the device name in the terminal? I am trying to port this application to Android and cant figure it out.

#lsusb shows the device but with no path
#mount only shows its mount point

Any help is great
thakns

I suppose ls /dev is out of the question?

Android is nontraditional Linux/UNIX in many ways, I'm not sure it has a proper /dev.

Ya I know what you mean by non-traditional for sure. With Busybox though I do have access to a lot of UNIX commands which is very helpfull. On the Android tablet this is what I am getting under /dev:

auditpipe		ptyp7			ptyra			ptytd			ptyw0			ttyp5			ttyr8			ttyt8			ttyvb
autofs			ptyp8			ptyrb			ptyte			ptyw1			ttyp6			ttyr9			ttyt9			ttyvc
autofs_control		ptyp9			ptyrc			ptytf			ptyw2			ttyp7			ttyra			ttyta			ttyvd
autofs_nowait		ptypa			ptyrd			ptyu0			ptyw3			ttyp8			ttyrb			ttytb			ttyve
bpf0			ptypb			ptyre			ptyu1			ptyw4			ttyp9			ttyrc			ttytc			ttyvf
bpf1			ptypc			ptyrf			ptyu2			ptyw5			ttypa			ttyrd			ttytd			ttyw0
bpf2			ptypd			ptys0			ptyu3			ptyw6			ttypb			ttyre			ttyte			ttyw1
bpf3			ptype			ptys1			ptyu4			ptyw7			ttypc			ttyrf			ttytf			ttyw2
console			ptypf			ptys2			ptyu5			ptyw8			ttypd			ttys0			ttyu0			ttyw3
cu.Bluetooth-Modem	ptyq0			ptys3			ptyu6			ptyw9			ttype			ttys000			ttyu1			ttyw4
cu.Bluetooth-PDA-Sync	ptyq1			ptys4			ptyu7			ptywa			ttypf			ttys001			ttyu2			ttyw5
disk0			ptyq2			ptys5			ptyu8			ptywb			ttyq0			ttys002			ttyu3			ttyw6
disk0s1			ptyq3			ptys6			ptyu9			ptywc			ttyq1			ttys1			ttyu4			ttyw7
disk0s2			ptyq4			ptys7			ptyua			ptywd			ttyq2			ttys2			ttyu5			ttyw8
disk1			ptyq5			ptys8			ptyub			ptywe			ttyq3			ttys3			ttyu6			ttyw9
disk2			ptyq6			ptys9			ptyuc			ptywf			ttyq4			ttys4			ttyu7			ttywa
dtrace			ptyq7			ptysa			ptyud			random			ttyq5			ttys5			ttyu8			ttywb
dtracehelper		ptyq8			ptysb			ptyue			rdisk0			ttyq6			ttys6			ttyu9			ttywc
fbt			ptyq9			ptysc			ptyuf			rdisk0s1		ttyq7			ttys7			ttyua			ttywd
fd			ptyqa			ptysd			ptyv0			rdisk0s2		ttyq8			ttys8			ttyub			ttywe
fsevents		ptyqb			ptyse			ptyv1			rdisk1			ttyq9			ttys9			ttyuc			ttywf
klog			ptyqc			ptysf			ptyv2			rdisk2			ttyqa			ttysa			ttyud			urandom
lockstat		ptyqd			ptyt0			ptyv3			sdt			ttyqb			ttysb			ttyue			vboxdrv
machtrace		ptyqe			ptyt1			ptyv4			stderr			ttyqc			ttysc			ttyuf			vboxnetctl
null			ptyqf			ptyt2			ptyv5			stdin			ttyqd			ttysd			ttyv0			vn0
pmCPUClient		ptyr0			ptyt3			ptyv6			stdout			ttyqe			ttyse			ttyv1			vn1
profile			ptyr1			ptyt4			ptyv7			systrace		ttyqf			ttysf			ttyv2			vn2
ptmx			ptyr2			ptyt5			ptyv8			tty			ttyr0			ttyt0			ttyv3			vn3
ptyp0			ptyr3			ptyt6			ptyv9			tty.Bluetooth-Modem	ttyr1			ttyt1			ttyv4			zero
ptyp1			ptyr4			ptyt7			ptyva			tty.Bluetooth-PDA-Sync	ttyr2			ttyt2			ttyv5
ptyp2			ptyr5			ptyt8			ptyvb			ttyp0			ttyr3			ttyt3			ttyv6
ptyp3			ptyr6			ptyt9			ptyvc			ttyp1			ttyr4			ttyt4			ttyv7
ptyp4			ptyr7			ptyta			ptyvd			ttyp2			ttyr5			ttyt5			ttyv8
ptyp5			ptyr8			ptytb			ptyve			ttyp3			ttyr6			ttyt6			ttyv9
ptyp6			ptyr9			ptytc			ptyvf			ttyp4			ttyr7			ttyt7			ttyva

sorry for the long output!
THere are a ton of TTY device names but I am not sure what all of them are for. I also don't see any USB.
Ill keep looking into it. I don't see any reason why my simple serial port logger that works flawlessly on any Linux machine so far can't be setup to work on Android.
A last note: when i try random device names the application does seem to find the name and connect....however while listening (I used the C library's select() statement) it is not getting anything coming in.

Cheers

---------- Post updated at 09:32 AM ---------- Previous update was at 09:25 AM ----------

OH NO my mistake. that was for my desktop. /dev from the device yields:

ace_dev
alarm
android_adb
ashmem
autofs
aw_i2c_ts2
binder
block
bus
cachefiles
cedar_dev
console
cpu_dma_latency
cpuctl
cuse
device-mapper
disp
ecompass_ctrl
full
fuse
g2d
graphics
i2c-0
i2c-1
i2c-2
input
kmsg
lcd
log
mali
mem
mtp_usb
mxc622x
network_latency
network_throughput
null
pa_dev
ppp
ptmx
pts
random
rfkill
rtc0
snd
socket
tty
tty0
tty1
tty10
tty11
tty12
tty13
tty14
tty15
tty16
tty17
tty18
tty19
tty2
tty20
tty21
tty22
tty23
tty24
tty25
tty26
tty27
tty28
tty29
tty3
tty30
tty31
tty32
tty33
tty34
tty35
tty36
tty37
tty38
tty39
tty4
tty40
tty41
tty42
tty43
tty44
tty45
tty46
tty47
tty48
tty49
tty5
tty50
tty51
tty52
tty53
tty54
tty55
tty56
tty57
tty58
tty59
tty6
tty60
tty61
tty62
tty63
tty7
tty8
tty9
ttyGS0
ttyGS1
ttyGS2
ttyGS3
ttyS0
ttyS1
ttyS2
ttyS3
ttyS4
ttyS5
ttyS6
ttyS7
tun
uinput
ump
urandom
usb
usb_accessory
vcs
vcs1
vcsa
vcsa1
video1
xt_qtaguid
zero

many sorries

Ugh... it looks like they just made every possible device without bothering to wonder which are actually present. Is tty.Bluetooth-Modem a symlink? Look for devices which are symlinks.

Can you insert some USB device an check which entry is used/modified? Check the syslog as well.

ya..not pretty.
I am using a serial to USB converter with hardware by Prolific. It is the pl2303 one.
when i call up lsmod on my Linux laptop that runs the application fine I see a module called: usbserial pl2303
when I call up lsmod on the android I don't see it which makes sense.

I am assuming this may be the reason why #lsusb returns seeing the device but /dev/ttyUSB0 doesnt get populated upon attaching the device.

I think my plan of attack is to find out how to get that module on there......thoughts?

---------- Post updated at 03:10 PM ---------- Previous update was at 03:07 PM ----------

Rudy, the system log outputs this when my device gets attached:

D/ViewRootImpl( 1579): pckname = com.prolific.pl2303hxdsimpletest
I/USB3G   (   92): event { 'add', '/devices/platform/sw-ohci.1/usb3/3-1', 'usb', '', 189, 266 }
I/USB3G   (   92): path : '/sys/devices/platform/sw-ohci.1/usb3/3-1'
I/USB3G   (   92): VID :size 5,vid_path '/sys/devices/platform/sw-ohci.1/usb3/3-1/idVendor',VID  '067b
I/USB3G   (   92): '.
I/USB3G   (   92): PID :size 5,Pid_path '/sys/devices/platform/sw-ohci.1/usb3/3-1/idProduct',PID  '2303
I/USB3G   (   92): '.
I/USB3G   (   92): cmd=/system/bin/usb_modeswitch.sh /system/etc/usb_modeswitch.d/067b_2303 &,
I/ActivityManager(  156): START {act=android.hardware.usb.action.USB_DEVICE_ATTACHED flg=0x10000000 cmp=com.prolific.pl2303hxdsimpletest/.PL2303HXDSimpleTest (has extras)} from pid 156
D/PL2303HXD_APLog( 1579): Enter onStart
D/PL2303HXD_APLog( 1579): Leave onStart
D/PL2303HXD_APLog( 1579): Enter onResume
D/PL2303HXD_APLog( 1579): onResume:android.hardware.usb.action.USB_DEVICE_ATTACHED
D/PL2303HXD_APLog( 1579): New instance : tw.com.prolific.driver.pl2303.PL2303Driver@4107dcc8
I/PL2303HXDDriver( 1579): enumerating
I/USB3G   (   92): excute ret : 0,err:No such file or directory
I/PL2303HXDDriver( 1579): Found device: 0BDA:8179
I/PL2303HXDDriver( 1579): iSupportedDevListCnt: 5
I/PL2303HXDDriver( 1579): Found device: 067B:2303
I/PL2303HXDDriver( 1579): iSupportedDevListCnt: 5
D/PL2303HXDDriver( 1579): cmd:toolbox ls /dev/bus/usb/003/011
V/su-binary( 1905): ----su-----
V/su-binary( 1905): argv[1]=-c
V/su-binary( 1905): argv[2]=chmod 666 /dev/bus/usb/*/*
D/PL2303HXDDriver( 1579): verify: /dev/bus/usb/003/011
D/PL2303HXD_APLog( 1579): onResume:enumerate succeeded!
D/PL2303HXD_APLog( 1579): Leave onResume
D/ViewRootImpl( 1579): pckname = com.prolific.pl2303hxdsimpletest
D/PL2303HXDDriver( 1579): UARTintf index = 0
D/PL2303HXDDriver( 1579): Found UsbInterface[mId=0,mClass=255,mSubclass=0,mProtocol=0,mEndpoints=[Landroid.os.Parcelable;@4108d9f0]
D/PL2303HXDDriver( 1579): claim interface succeeded
I/PL2303HXDDriver( 1579): EP: 0x81
I/PL2303HXDDriver( 1579): EP: 0x02
I/PL2303HXDDriver( 1579): Bulk Endpoint
I/PL2303HXDDriver( 1579): EP: 0x83
I/PL2303HXDDriver( 1579): Bulk Endpoint
I/PL2303HXDDriver( 1579): setPLEndpoints succeeded
D/PL2303HXD_APLog( 1579): Enter onStop
D/PL2303HXD_APLog( 1579): Leave onStop

One thought: Just because lsusb shows it, does not mean your system has a driver for it. It recognizes by device serial numbers, of which lsusb has its own independent list. (much like lspci.)

If you can find it in /sys/ though, /sys/ can tell you the major and minor numbers of the device:

$ cat /sys/block/sdc/dev
8:32

$ ls -l /dev
...
brw-rw---- 1 root disk    8,  32 Oct  1 13:30 sdc
...

$

interesting....the device doesnt show up in /sys/block when plugged in.
HOWEVER, when i plug in a random usb key (dongle) type is see something being listed as sda

prob driver issues heh?

You would not see it in /sys/block, block devices are disks. I used my hard drive as an off-the-cuff example of how to get the major/minor numbers. It might be found under /sys/class/tty/. It is full of virtual terminals which you can ignore, but will have serial ports as well.

Lots of devices these days include a little hard drive thing along with the device. It might have device drivers on it or promotional software. Or it might be something else entirely, when you can see the hardware the way Linux does some things just act strange.

yup you're right. was /sys/class/tty but nothing populated in here on attachment...

Your system may not have a driver for that device, then. Or it may have a driver but not recognize that device as being compatible with it.

ya been hacking away here and that for sure is the problem.
I am going to look into devices allowing rs232-USB that have drivers for android readily availalble as this could be a long road.

I wonder if it has the FTDI driver built-in. Lots of things use it.

What about /dev/bus/usb/003/011 ?

/dev/bus/usb isn't for serial ports, it is for raw USB communication. His software would have to speak USB protocol, and know how to use it to talk to the device.

Sometimes this is necessary for strange cameras, but isn't often done.

1 Like

nothing...

Nothing about what?

haha sorry, that was in another forum.

but so far no success. it definitely is a driver issue and so that is why no /dev/ttyUSB* populates in /dev upon plug in.

I have seen that some companies to provide drivers for these adapters so kind of exploring options there.

Also, a lot of people mention that you must OTG usb port....dont know why this would matter as my tablet has a usb2.0 port already.

updates as they come...

They're just saying it must be a USB host port not a USB client port. If you had an android phone you could be stuck with a client port.

Your tablet obviously detects it, so must be acting as a host port. It doesn't have the right driver unfortunately.

The manufacturer is unlikely to have a linux driver, particularly one for Android. Many of these generic USB things work with common drivers though -- with a twiddled USB serial number so the linux driver no longer detects it.

ok then....
well another day here we go...ill see what I can uncover.
you are definitely right...such a PITA though.

trying some different paths here this morning and I notice that in /dev with a USB dongle plugged in I get a 4:0:0:0 number in there. it increments by 1 every time I plug it bag in.....anyone know what that number represents are how I can use it?

---------- Post updated at 09:32 AM ---------- Previous update was at 09:26 AM ----------

I also have come accross this website:

Products

which they say they provide a driver for Android and this is the cable chip I am using....I just am not quite sure how to pull the driver out and install it on the tablet.....duh