linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How do assign specific nodes to 2-port USB-to-serial adapter?
@ 2005-10-18 22:41 J McBane
  2005-10-18 23:35 ` Oli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: J McBane @ 2005-10-18 22:41 UTC (permalink / raw)
  To: linux-hotplug

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"

I'm thinking that one of the "simple printf-like string substitutions" will do
the trick but none have worked thus far.

Any suggestions?

Thanks in advance,

J McBane
jmcbane a grandecom.net



-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do assign specific nodes to 2-port USB-to-serial adapter?
  2005-10-18 22:41 How do assign specific nodes to 2-port USB-to-serial adapter? J McBane
@ 2005-10-18 23:35 ` Oli
  2005-10-19 15:20 ` Oli
  2005-10-19 17:41 ` J McBane
  2 siblings, 0 replies; 4+ messages in thread
From: Oli @ 2005-10-18 23:35 UTC (permalink / raw)
  To: linux-hotplug


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




-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do assign specific nodes to 2-port USB-to-serial adapter?
  2005-10-18 22:41 How do assign specific nodes to 2-port USB-to-serial adapter? J McBane
  2005-10-18 23:35 ` Oli
@ 2005-10-19 15:20 ` Oli
  2005-10-19 17:41 ` J McBane
  2 siblings, 0 replies; 4+ messages in thread
From: Oli @ 2005-10-19 15:20 UTC (permalink / raw)
  To: linux-hotplug

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do assign specific nodes to 2-port USB-to-serial adapter?
  2005-10-18 22:41 How do assign specific nodes to 2-port USB-to-serial adapter? J McBane
  2005-10-18 23:35 ` Oli
  2005-10-19 15:20 ` Oli
@ 2005-10-19 17:41 ` J McBane
  2 siblings, 0 replies; 4+ messages in thread
From: J McBane @ 2005-10-19 17:41 UTC (permalink / raw)
  To: linux-hotplug

Quoting Oli <ocomber@cmedresearch.com>:

> 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
>
>

"If the device is well behaved, it should initialise the ports in the same order
each time."

That's just it.  I guess the device is not well behaved.  Sometimes serial ports
1&2 are named ttyUSB0&ttyUSB1 and serial ports 3&4 are named ttyUSB2&ttyUSB3 (as
one would expect).  But sometimes the opposite happens, where serial ports 3&4
are named ttyUSB0&ttyUSB1 and serial ports 1&2 are named ttyUSB2&ttyUSB3.

For some reason, udev/hotplug is not consistently seeing/naming each of these
2-port "sub devices".

Because of this behavior, I don't think your suggestions will help, because it's
based on the order the devices are seen/named.  I actually just tried them and
they didn't work.  I know that the serial number ending with "-0" is the device
with serial ports 1&2, so I'm basically trying to find a way to tell
udev/hotplug "work with the device ending with serial number "-0" first".

I will try your latest suggestion "usbserial%k to get usbserial1, usbserial2
etc" and let you know what happens.

What mechanism controls the order of which devices are detected/seen/named?  It
seems that this is what the issue boils down to.

Thanks again for your help, Oli.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-19 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 22:41 How do assign specific nodes to 2-port USB-to-serial adapter? J McBane
2005-10-18 23:35 ` Oli
2005-10-19 15:20 ` Oli
2005-10-19 17:41 ` J McBane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).