From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oli Date: Wed, 19 Oct 2005 15:20:28 +0000 Subject: Re: How do assign specific nodes to 2-port USB-to-serial adapter? Message-Id: <1129735228.8725.12.camel@localhost.localdomain> List-Id: References: <1129675265.43557a0137b76@webmail.grandecom.net> In-Reply-To: <1129675265.43557a0137b76@webmail.grandecom.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Tue, 2005-10-18 at 20:47 -0500, J McBane wrote: > Oli wrote: > > >Hey J, > > > >On Tue, 2005-10-18 at 17:41 -0500, J McBane wrote: > > > > > >>Greetings, > >> > >>My USB-to-serial adapter (gives me 2 serial ports) is currently being named > >>ttyUSB0 and ttyUSB1. I would like to change the name of the nodes to test0 and > >>test1, for example. > >> > >>I understand how to normally accomplish this, except this device shares the same > >>serial number and ID, according to "udevinfo -a -p /sys/class/tty/ttyUSB0" and > >>"udevinfo -a -p /sys/class/tty/ttyUSB1". > >> > >>I don't know how to tell udev/hotplug how to differentiate between the two > >>serial ports. > >> > >>The best I can come up with is the following, which only gives me a test0 node > >>(and no ttyUSB nodes): > >>BUS="usb", SYSFS{serial}="V32408622-0", NAME="test0" > >>BUS="usb", SYSFS{serial}="V32408622-0", NAME="test1" > >> > >> > >> > > > >You could try a little something like this: > > > >BUS="usb", SYSFS{serial}="V32408622-0", NAME="%k", SYMLINK="test%n" > > > >Or if you're feeling cheeky, maybe you could: > > > >BUS="usb", SYSFS{serial}="V32408622-0", NAME="%k", SYMLINK="%s{serial}% > >n" > > > >With a bit of digging around in sysfs, I'm sure you could find something > >more meaningful to put in the symlink name than 'serial'. > > > >You're probably being a bit restrictive by putting the whole serial in > >there. It'd be better to use something like model number. > > > >Have a look at the udev manual page. All sorts of fun stuff in > >there :0) > > > >Check the version of udev you're running too - I know the '%s' stuff was > >patched a bit some time ago - v0.75ish, IIRC ? > > > >Also note that the rules will (I think) stop at the first match. This > >is why your test1 device never gets created. > > > >Hope this helps. > > > >Cheers, > >-Oli > > > > > > > > > > > > > Oli, > Hi J, > I hope you don't mind me replying directly to you, as to not spam the list. Not a problem :0) I've put the list back on this reply though, so everyone can jump in and give you some better advice :0) > > I noticed %s in the udev man page but wasn't sure how to "use it". > There were no examples of %s (I like examples). Yeah, the examples for that one are a bit thin on the ground. It works exactly like the sysfs{attribute} rule, except it substitutes the value into the name or symlink. > > Something I didn't mention is that my device actually has 4 serial ports > (two 2-port devices in one box). Righto. > > udev/hotplug sees two devices, each with a separate serial number, but > the same "model number", so I don't think I'll be able to use the model > number. If the device is well behaved, it should initialise the ports in the same order each time. When you use %k, it substitutes the kernel device number - eg, 1 for hda1, 2 for hda2 etc - and they'll always refer to the same port. You can use the model number with a %k on the end to get different devices/symlinks created from the same rule. The trick is finding a sysfs attribute that is meaningful to you - maybe the make of the board..? Or forget that, and use usbserial%k to get usbserial1, usbserial2 etc > > Thanks for the prompt reply and suggestion! No probs :0) > > Cheers, > > J McBane ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel