[ale] USB port identification

Alex Carver agcarver+ale at acarver.net
Thu Nov 19 12:42:17 EST 2015


On 2015-11-19 09:23, Chris Fowler wrote:
>> From: "Alex Carver" <agcarver+ale at acarver.net>
>> To: ale at ale.org
>> Sent: Thursday, November 19, 2015 11:51:03 AM
>> Subject: Re: [ale] USB port identification
> 
>> /devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.5
> 
>> Which would be port five on a hub attached to bus 1, port 4.
> 
> It seems we have a winner. That path never changed. The device # did. At this point I can not remember if I used that in my original script or if I used the device # as shown in lsusb. I'll look into that. I'm pretty sure I can tell udev to send me the above path. I can then grok the values out as required and refer to a table of assignments. 
> 
> If vendorId = X and productID = Y and USB Port = Z 
> then ln -sf real kernel device /dev/us2 

You only need to feed the last part of the path to udev.:

KERNELS=="1-1.4.2",NAME="namehere"

For example, I have two serial adapters on one machine.  They sometimes
get out of order on boot without udev rules so I have these rules:

ACTION=="add",KERNEL=="ttyUSB*",SUBSYSTEMS=="usb",KERNELS=="1-1.3.1.4:1.0",SYMLINK+="dymo"
ACTION=="add",KERNEL=="ttyUSB*",SUBSYSTEMS=="usb",KERNELS=="1-1.3.1.3:1.0",SYMLINK+="supra"


This ensures the symlinks follow the appropriate physical device (a
modem and a printer) no matter how they decide to get loaded.  In this
case the dymo printer is located at Bus 1, Root 1, Hub Port 3, Hub Port
1, Hub Port 4 (it's a raspberry pi with several on-board hub chips)

The :1.0 is configuration 1, interface 0 (some devices can have more
than one for things like full speed versus high speed).


More information about the Ale mailing list