(disclaimer: I'm no linux kernel expert, so my post may turn out to be
inaccurate).
AFAIK sysfs is a linux kernel feature, independent of the availability of
udevd, so navigating /sys/ is the "canonical" way of obtaining info on kernel
objects and attributes. (And yes, it is the kernel that enumerates USB devices
and then notifies udevd)
However Tiger is right, the search heuristics should be more accurate/simple.
On my linux system I have
$ tree /sys/bus/usb/devices
/sys/bus/usb/devices
|-- 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1/1-0:1.0
|-- 1-5 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1/1-5
|-- 1-5.2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.2
|-- 1-5.2:1.0 ->
../../../devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.2/1-5.2:1.0
|-- 1-5:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0
|-- 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2/2-0:1.0
|-- 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3/3-0:1.0
|-- 3-2 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3/3-2
|-- 3-2:1.0 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0
|-- 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.2/usb4/4-0:1.0
|-- usb1 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1
|-- usb2 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2
|-- usb3 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3
`-- usb4 -> ../../../devices/pci0000:00/0000:00:1d.2/usb4
and
$ tree /sys/bus/usb-serial/devices
/sys/bus/usb-serial/devices
`-- ttyUSB0 ->
../../../devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.2/1-5.2:1.0/ttyUSB0
So a possible alternative way of finding the pairing could be:
foreach symlink in /sys/bus/usb-serial/devices
navigate upwards the symlink until the relevant info (busnum, devnum,
idProduct, idVendor, etc.) is found
For example I would code this in bash as
$ for i in /sys/bus/usb-serial/devices/*; do echo TTY=$(basename $i) bus=$(<
$i/../../busnum) dev=$(< $i/../../devnum) USB=$(< $i/../../idVendor):$(<
$i/../../idProduct); done
TTY=ttyUSB0 bus=1 dev=10 USB=0403:6001
(Please note that for navigating upwards I do not break the path but just add
'/..')
Bye
Stefano
On 06 Oct 2014, at 13:45, Der Tiger <der.tiger.o...@arcor.de> wrote:
> Hi,
>
>> 1. Recursively search /sys/devices for "busnum" (which seems to
>> indicate a USB device)
> Which, IMHO, would suggest devd or udevd to be required, since the
> enumeration is done by the daemon.
------------------------------------------------------------------------------
Slashdot TV. Videos for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers