|
From: Paul A. <pau...@gm...> - 2014-09-30 18:04:54
|
Ok, here is my code for mapping USB devices to tty devices. It's a script and needs to be tested on various platforms. ----------------------------------- #!/bin/sh # find all directories with busnum (they are USB devices) usbdirs=$(find /sys/devices -name "busnum" -printf "%h\n") # look at every USB for f in $usbdirs do b=$(cat $f/busnum) d=$(cat $f/devnum) p=$(cat $f/idProduct) v=$(cat $f/idVendor) # find tty devices under each usb t=$(find $f -name "tty[AU]*" -prune -printf "%f\n") if [ -n "$t" ] then if [ $(echo $t | wc -w) == 1 ] then echo echo $t echo USB device number $d echo $b:$d $v:$p echo Full path: $f fi fi done ----------------------------------- On my desktop (Fedora with lots of devices: ttyUSB6 USB device number 14 3:14 0711:0230 Full path: /sys/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2.1/3-3.2.1.7/3-3.2.1.7.2 ttyUSB6 USB device number 12 3:12 0451:2036 Full path: /sys/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2.1/3-3.2.1.7 ttyUSB6 USB device number 7 3:7 0409:0050 Full path: /sys/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2.1 ttyUSB0 USB device number 3 3:3 0403:6001 Full path: /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4 ttyACM0 USB device number 39 1:39 04d8:f897 Full path: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1 ttyUSB1 USB device number 33 1:33 0403:6001 Full path: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3 ttyUSB7 USB device number 37 1:37 1a86:7523 Full path: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4 I'll need to remove duplicates caused by hubs being included. It looks like choosing either the longer path name or higher device number can select the device and not hub. Paul On Tue, Sep 30, 2014 at 9:50 AM, Stefano Miccoli <mo...@ic...> wrote: > > On 30 Sep 2014, at 08:32, Johan Ström <jo...@st...> wrote: > > Hi all, > > picking this up again. Lets summarize the main points: > > * auto-detection can only be relied on for certain pure USB devices > * auto-detection can not be relied on when "standard" serial bridge chips > are used > * if we can resolve /dev/ttyUSB0 to a particular USB device, we can > potentially select a smarter (i.e. improved FTDI) code path instead of > regular read/write from the tty device. > * /dev/ttyUSB0 is not stable, unless explicit devd setup is done. > * this makes alterantive OWFS device addressing interesting, by specifying > USB serial. this would avoid devd all together. > > > excellent recap. Let me add another remark. > > It seems that Debian, and most of the developers like to run owserver and > companion programs as root. Personally I do not like this: on production > systems I run owserver without root privileges, so udev/devd is still > necessary to set appropriate permissions to /dev files. > > Unfortunately this means that with serial emulators some manual setup is > needed: inspecting syslog files, noting the device serial number, modifying > the udev/devd script. Alternatively owserver and family should drop root > privileges after startup. > > Stefano > > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > > http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk > _______________________________________________ > Owfs-developers mailing list > Owf...@li... > https://lists.sourceforge.net/lists/listinfo/owfs-developers > > |