* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
@ 2010-01-30 18:25 ` Paul Bender
2010-01-30 18:27 ` David Zeuthen
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Paul Bender @ 2010-01-30 18:25 UTC (permalink / raw)
To: linux-hotplug
On 1/30/2010 10:05 AM, Paul Dugas wrote:
> First, please point me where I should be asking if this is not the
> place. Thanks.
>
> I've got a number of USB devices I need to connect to a data-logging
> machine. Each device presents as 3 USB serial ports which are
> properly recognized and setup as ttyUSB[0-2] once I added the right
> vendor and product numbers to the module loader configs. When I
> connect the second device, I get ttyUSB[3-5]. I've been able to setup
> udev rules that recognize the serial numbers for each of the devices
> and can setup symlinks; i.e. ttyLogger1USB[0-2] -> ttyUSB?.
> Something like so...
>
> KERNEL="ttyUSB*", SYSFS{serial}="111", SYMLINK+="ttyLogger1USB%n"
> KERNEL="ttyUSB*", SYSFS{serial}="222", SYMLINK+="ttyLogger2USB%n"
> KERNEL="ttyUSB*", SYSFS{serial}="333", SYMLINK+="ttyLogger3USB%n"
>
> My hitch is that the %n values on the end of the SYMLINK setting
> result in 0-2 for the first logger found, 3-5 for the second, etc. I
> really want them to be 0-2 for all of the loggers. But, looking at
> the udevinfo for the 3 ports on one logger, they're identical.
>
> I tried adding a PROGRAM setting to run a little script that looked to
> count the /dev/ttyLogger1USB* devices had already been created and it
> always returned 0. Are the device files and symlinks created in
> parallel or in bulk at the end and thus this approach wouldn't work?
>
> I tried another PROGRAM that opened the port and polled the logger to
> see what port this was (that's supported by the device's protocol) but
> the device file didn't exist yet. Is there a way to trigger this
> approach after the device file has been created? Is there a way to
> temporarily create the device in the script instead?
>
> Anyone got a suggestion on how to solve this?
I suspect that the device presents itself as 3 USB serial interfaces on
one USB device. If so, then you should be able to use bInterfaceNumber
to set the USB serial device number. For example,
KERNEL="ttyUSB*", SYSFS{serial}="111", \
SYMLINK+="ttyLogger1USB$attr{bInterfaceNumber}"
KERNEL="ttyUSB*", SYSFS{serial}="222", \
SYMLINK+="ttyLogger2USB$attr{bInterfaceNumber}"
KERNEL="ttyUSB*", SYSFS{serial}="333", \
SYMLINK+="ttyLogger3USB$attr{bInterfaceNumber}"
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
2010-01-30 18:25 ` Paul Bender
@ 2010-01-30 18:27 ` David Zeuthen
2010-01-30 18:34 ` Greg KH
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: David Zeuthen @ 2010-01-30 18:27 UTC (permalink / raw)
To: linux-hotplug
On Sat, 2010-01-30 at 13:05 -0500, Paul Dugas wrote:
> I tried adding a PROGRAM setting to run a little script that looked to
> count the /dev/ttyLogger1USB* devices had already been created and it
> always returned 0. Are the device files and symlinks created in
> parallel or in bulk at the end and thus this approach wouldn't work?
>
> I tried another PROGRAM that opened the port and polled the logger to
> see what port this was (that's supported by the device's protocol) but
> the device file didn't exist yet. Is there a way to trigger this
> approach after the device file has been created? Is there a way to
> temporarily create the device in the script instead?
>
> Anyone got a suggestion on how to solve this?
You should be able to use IMPORT and $tempnode - see the udev(7) man
page and, say, /lib/udev/rules.d/60-persistent-storage.rules for an
example of where this is used.
David
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
2010-01-30 18:25 ` Paul Bender
2010-01-30 18:27 ` David Zeuthen
@ 2010-01-30 18:34 ` Greg KH
2010-01-30 18:50 ` Paul Dugas
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-01-30 18:34 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 01:05:27PM -0500, Paul Dugas wrote:
> First, please point me where I should be asking if this is not the
> place.? Thanks.
>
> I've got a number of USB devices I need to connect to a data-logging
> machine.? Each device presents as 3 USB serial ports which are
> properly recognized and setup as ttyUSB[0-2] once I added the right
> vendor and product numbers to the module loader configs.? When I
> connect the second device, I get ttyUSB[3-5].? I've been able to setup
> udev rules that recognize the serial numbers for each of the devices
> and can setup symlinks; i.e. ttyLogger1USB[0-2] -> ttyUSB?.
> Something like so...
>
> KERNEL="ttyUSB*", SYSFS{serial}="111", SYMLINK+="ttyLogger1USB%n"
> KERNEL="ttyUSB*", SYSFS{serial}="222", SYMLINK+="ttyLogger2USB%n"
> KERNEL="ttyUSB*", SYSFS{serial}="333", SYMLINK+="ttyLogger3USB%n"
Have you looked at the links in /dev/serial/? that should work for what
you are trying to accomplish.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (2 preceding siblings ...)
2010-01-30 18:34 ` Greg KH
@ 2010-01-30 18:50 ` Paul Dugas
2010-01-30 18:50 ` Paul Dugas
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Paul Dugas @ 2010-01-30 18:50 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 1:25 PM, Paul Bender <pebender@san.rr.com> wrote:
> I suspect that the device presents itself as 3 USB serial interfaces on one
> USB device. If so, then you should be able to use bInterfaceNumber to set
> the USB serial device number. For example,
>
> KERNEL="ttyUSB*", SYSFS{serial}="111", \
> SYMLINK+="ttyLogger1USB$attr{bInterfaceNumber}"
> KERNEL="ttyUSB*", SYSFS{serial}="222", \
> SYMLINK+="ttyLogger2USB$attr{bInterfaceNumber}"
> KERNEL="ttyUSB*", SYSFS{serial}="333", \
> SYMLINK+="ttyLogger3USB$attr{bInterfaceNumber}"
Yeah, started down that road at the start but no joy.
# udevinfo -a -p /sys/class/tty/ttyUSB0 >/tmp/udevinfo.usb0
# udevinfo -a -p /sys/class/tty/ttyUSB1 >/tmp/udevinfo.usb1
# diff diff /tmp/udevinfo.usb0 /tmp/udevinfo.usb1
8,9c8,9
< looking at device '/class/tty/ttyUSB0':
< KERNEL="ttyUSB0"
---
> looking at device '/class/tty/ttyUSB1':
> KERNEL="ttyUSB1"
11c11
< SYSFS{dev}="188:0"
---
> SYSFS{dev}="188:1"
13,14c13,14
< looking at parent device
'/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB0':
< ID="ttyUSB0"
---
> looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB1':
> ID="ttyUSB1"
#
There is a bInterfaceNumber in
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.1/1-1.1:1.0 under which
I find ttyUSB0/, ttyUSB1/ and ttyUSB2/. I think the USB
implementation on this logger just didn't take what I'm trying to do
into consideration.
Thanks,
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (3 preceding siblings ...)
2010-01-30 18:50 ` Paul Dugas
@ 2010-01-30 18:50 ` Paul Dugas
2010-01-30 18:59 ` Paul Dugas
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Paul Dugas @ 2010-01-30 18:50 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 1:34 PM, Greg KH <greg@kroah.com> wrote:
> Have you looked at the links in /dev/serial/? that should work for what
> you are trying to accomplish.
Alas, this is a RedHat machine at the moment so no /dev/serial :(
P
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (4 preceding siblings ...)
2010-01-30 18:50 ` Paul Dugas
@ 2010-01-30 18:59 ` Paul Dugas
2010-01-30 19:58 ` David Zeuthen
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Paul Dugas @ 2010-01-30 18:59 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 1:27 PM, David Zeuthen <david@fubar.dk> wrote:
> You should be able to use IMPORT and $tempnode
And it seems the idea of getting IDs from the devices themselves is
not off-the-wall at all. Sweet. I completely missed the $tempnode
entry in the man page.
Is there a reason I should use IMPORT{program} instead of PROGRAM like so...
KERNEL="ttyUSB*", SYSFS{serial}="111", \
PROGRAM="logger_port $N", \
SYMLINK+="ttyLogger1USB%c"
I ask mainly because I'm not entirely sure what "environment key format" is.
Thanks much.
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (5 preceding siblings ...)
2010-01-30 18:59 ` Paul Dugas
@ 2010-01-30 19:58 ` David Zeuthen
2010-01-30 20:36 ` Paul Dugas
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: David Zeuthen @ 2010-01-30 19:58 UTC (permalink / raw)
To: linux-hotplug
On Sat, 2010-01-30 at 13:59 -0500, Paul Dugas wrote:
> On Sat, Jan 30, 2010 at 1:27 PM, David Zeuthen <david@fubar.dk> wrote:
> > You should be able to use IMPORT and $tempnode
>
> And it seems the idea of getting IDs from the devices themselves is
> not off-the-wall at all. Sweet. I completely missed the $tempnode
> entry in the man page.
>
> Is there a reason I should use IMPORT{program} instead of PROGRAM like so...
>
> KERNEL="ttyUSB*", SYSFS{serial}="111", \
> PROGRAM="logger_port $N", \
> SYMLINK+="ttyLogger1USB%c"
>
> I ask mainly because I'm not entirely sure what "environment key format" is.
I'm not sure that the output of PROGRAM is parsed the same way it is for
IMPORT - in fact, I think it's just ignored for PROGRAM - Kay? Anyway,
the general idea is something like this
SUBSYSTEM="tty", SUBSYSTEMS="usb", IMPORT{program}="logger_import
$tempnode", SYMLINK+="ttyLogger$env{LOGGER_DEVICE_NUMBER}port
$env{LOGGER_PORT_NUMBER}"
where the logger_import program writes lines like this
LOGGER_PORT_NUMBERB
LOGGER_DEVICE_NUMBERC
on stdout which is then imported into the environment for the device
(and thus available for later rules and via libudev).
David
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (6 preceding siblings ...)
2010-01-30 19:58 ` David Zeuthen
@ 2010-01-30 20:36 ` Paul Dugas
2010-01-31 0:47 ` Greg KH
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Paul Dugas @ 2010-01-30 20:36 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 2:58 PM, David Zeuthen <david@fubar.dk> wrote:
> I'm not sure that the output of PROGRAM is parsed the same way it is for
> IMPORT - in fact, I think it's just ignored for PROGRAM - Kay? Anyway,
> the general idea is something like this
According to udev(7) on this RHEL5.4 machine (udev-095-14.21.el5),
RESULT can be matched against the output of the last PROGRAM call and
$result or %c can be use in substitutions. Still, the idea of reading
both the serial number and the port number from the logger would allow
me to get by with a single udev rule along the lines of what you
wrote.
Thanks much for your input. Looks like exactly what I needed.
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (7 preceding siblings ...)
2010-01-30 20:36 ` Paul Dugas
@ 2010-01-31 0:47 ` Greg KH
2010-01-31 1:27 ` Paul Dugas
2010-01-31 2:55 ` Greg KH
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-01-31 0:47 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 01:50:57PM -0500, Paul Dugas wrote:
> On Sat, Jan 30, 2010 at 1:34 PM, Greg KH <greg@kroah.com> wrote:
> > Have you looked at the links in /dev/serial/? that should work for what
> > you are trying to accomplish.
>
> Alas, this is a RedHat machine at the moment so no /dev/serial :(
That shouldn't matter, what version are you running?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (8 preceding siblings ...)
2010-01-31 0:47 ` Greg KH
@ 2010-01-31 1:27 ` Paul Dugas
2010-01-31 2:55 ` Greg KH
10 siblings, 0 replies; 12+ messages in thread
From: Paul Dugas @ 2010-01-31 1:27 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 7:47 PM, Greg KH <greg@kroah.com> wrote:
> On Sat, Jan 30, 2010 at 01:50:57PM -0500, Paul Dugas wrote:
>> On Sat, Jan 30, 2010 at 1:34 PM, Greg KH <greg@kroah.com> wrote:
>> > Have you looked at the links in /dev/serial/? that should work for what
>> > you are trying to accomplish.
>>
>> Alas, this is a RedHat machine at the moment so no /dev/serial :(
>
> That shouldn't matter, what version are you running?
This is on an RHEL5.4 machine with a package named udev-095-14.21.el5.
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Multi-serial USB Device
2010-01-30 18:05 Multi-serial USB Device Paul Dugas
` (9 preceding siblings ...)
2010-01-31 1:27 ` Paul Dugas
@ 2010-01-31 2:55 ` Greg KH
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-01-31 2:55 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jan 30, 2010 at 08:27:13PM -0500, Paul Dugas wrote:
> On Sat, Jan 30, 2010 at 7:47 PM, Greg KH <greg@kroah.com> wrote:
> > On Sat, Jan 30, 2010 at 01:50:57PM -0500, Paul Dugas wrote:
> >> On Sat, Jan 30, 2010 at 1:34 PM, Greg KH <greg@kroah.com> wrote:
> >> > Have you looked at the links in /dev/serial/? that should work for what
> >> > you are trying to accomplish.
> >>
> >> Alas, this is a RedHat machine at the moment so no /dev/serial :(
> >
> > That shouldn't matter, what version are you running?
>
> This is on an RHEL5.4 machine with a package named udev-095-14.21.el5.
Yes, you are right, that is too old :(
^ permalink raw reply [flat|nested] 12+ messages in thread