Author Topic: Interrogating The Usb Serial Devices  (Read 5493 times)

jfr

  • Newbie
  • *
  • Posts: 36
    • View Profile
Interrogating The Usb Serial Devices
« on: August 01, 2007, 09:56:57 pm »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 3706
    • View Profile
Interrogating The Usb Serial Devices
« Reply #1 on: August 02, 2007, 04:37:04 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.
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

jfr

  • Newbie
  • *
  • Posts: 36
    • View Profile
Interrogating The Usb Serial Devices
« Reply #2 on: August 03, 2007, 05:31:10 am »
Quote
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.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=165678\"][{POST_SNAPBACK}][/a][/div]
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 :-(