On Thu, 5 Apr 2012, Dave Mielke wrote: > If I know the correct usbfs path (e.g. /proc/bus/usb/002/004) and/or the > correct sysfs path (e.g. /sys/dev/char/189:131), what's the best way (assuming > there is one) to figure out what the corresponding /dev/ttyUSBn serial device > is? This question does not have a unique answer; a single USB serial device can contain multiple ports and thus correspond to multiple /dev/ttyUSBn devices. There are several ways to look through sysfs for the information you want, although some of them may not work with older kernels. As an example I just plugged a PL2303 device into my computer, and it is now registered as /dev/bus/usb/008/002 (obviously only the "008/002" part is significant; it means the same as /proc/bus/usb/008/002) and as /sys/dev/char/189:897. There's no direct way to match "008/002" with a USB device, so you have to do a search. It means bus 8, device 2, so you would have to look through all the directories matching "/sys/bus/usb/devices/8-*" for one where the devnum file contains 2: $ for a in "/sys/bus/usb/devices/8-*/devnum" ; do > echo -n $a ': ' ; cat $a ; done /sys/bus/usb/devices/8-2/devnum : 2 Alternatively, starting from the /sys/dev entry: $ ls -l /sys/dev/char/189:897 lrwxrwxrwx 1 root root 0 Apr 6 10:27 /sys/dev/char/189:897 -> ../../devices/pci0000:00/0000:00:1d.3/usb8/8-2/ Either way we find the "8-2" path. Given that path, finding the corresponding ttyUSBn device name is pretty easy: $ echo /sys/bus/usb/devices/8-2/*/ttyUSB* /sys/bus/usb/devices/8-2/8-2:1.0/ttyUSB0 But here's where you might get multiple results, because with a multi-port device you'd see something more like this: $ echo /sys/bus/usb/devices/8-2/*/ttyUSB* /sys/bus/usb/devices/8-2/8-2:1.0/ttyUSB0 /sys/bus/usb/devices/8-2/8-2:1.1/ttyUSB1 Alternatively, you can search the ttyUSB* symlinks in /sys/class/tty to see which matches the USB path: $ ls -l /sys/class/tty/ttyUSB* | grep '/8-2/' lrwxrwxrwx 1 root root 0 Apr 6 10:26 /sys/class/tty/ttyUSB0 -> ../../devices/pci0000:00/0000:00:1d.3/usb8/8-2/8-2:1.0/ttyUSB0/tty/ttyUSB0/ Here there's only one match, but in theory there could be more. Hope this helps, Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html