Help - Search - Members - Calendar
Full Version: Interrogating The Usb Serial Devices
OESF Forums > Distros, Development, and Model Specific Forums > Everything Development > Linux Applications
jfr
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
speculatrix
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.
jfr
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 :-(
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.