OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

> Interrogating The Usb Serial Devices, Which hardware is on ttyUSBn?
jfr
post Aug 1 2007, 05:56 PM
Post #1





Group: Members
Posts: 36
Joined: 29-March 05
Member No.: 6,732



I've been wrestling with this, and it's time to give up and ask the experts.

C3000 with stock ROM, but portability desired.

My program will communicate with two separate USB serial devices, which will appear on /dev/ttyUSB0-1. I can probe the devices to find out which device is on which tty, but if there are other serial devices connected, the probing would be likely to upset their operation. (The stock ROM has only two serial devices, but mknod seems happy to create more, and I'd like my program to assume that other devices could be present.)

The devices are identified by their Manufacturer, Product and SerialNumber strings in the output of lsusb -v, but that gives me two problems:
1. lsusb -v has to be run as root; I'd prefer my program not to need root privileges.
2. Although it identifies the devices, it still doesn't answer the question of which tty each is connected to.

I can get my program to run dmesg and then parse the output, and I've had some success there - but:
1. Parsing the dmesg output is hardly elegant, and presumably highly non-portable, not to say driver-dependent.
2. dmesg appears to use a circular buffer, and the information I need is not necessarily still present when I need it.

The question in its most simplified form:
How can my program find the manufacturer, product and serial number strings (as listed by lsusb) of the hardware connected to a given ttyUSB port, with bonus points for elegance and portability?

As usual, enlightenment would be much appreciated.

Cheers

John
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
speculatrix
post Aug 2 2007, 12:37 PM
Post #2





Group: Admin
Posts: 3,281
Joined: 29-July 04
From: Cambridge, England
Member No.: 4,149



QUOTE
can my program find the manufacturer, product and serial number strings (as listed by lsusb) of the hardware connected to a given ttyUSB port

that's a good question, and I don't know.

could you use sudo to allow lsusb to be run by non-priv, or, make the file setuid? It's not suid on my x86 desktop, but still prints *some* useful things.
Go to the top of the page
 
+Quote Post
jfr
post Aug 3 2007, 01:31 AM
Post #3





Group: Members
Posts: 36
Joined: 29-March 05
Member No.: 6,732



QUOTE(speculatrix @ Aug 2 2007, 09:37 PM)
QUOTE
can my program find the manufacturer, product and serial number strings (as listed by lsusb) of the hardware connected to a given ttyUSB port

that's a good question, and I don't know.

could you use sudo to allow lsusb to be run by non-priv, or, make the file setuid? It's not suid on my x86 desktop, but still prints *some* useful things.
*


I could certainly do that, but lsusb still doesn't give the vital information as to which ttyUSB port each piece of hardware is connected to.

Hmm. If you of all people don't know the answer, this is even tougher than I'd imagined :-(
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 24th October 2014 - 10:51 AM