LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2010, 06:02 PM   #1
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Rep: Reputation: 15
Question Writing udev rules on Ubuntu 9.10 for two ports with the same product and vendor IDs


Hi everyone,

I have been trying to figure this out for a long time now and can't seem to get it to work. I have three serial ports I need to communicate with. The first one works, but the other two, which have identical product and vendor IDs, do not. This is what I have so far under /etc/udev/rules.d/10-local.rules/

Code:
kernel=="6-2", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK="Driver1&2"
kernel=="6-1", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK="Driver3&4"
kernel=="7-2", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK="HCS12"
And this is what lsusb gives:
Code:
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 04f2:b070 Chicony Electronics Co., Ltd 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 006 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Any help on this matter is strongly appreciated.

Thanks,
Ian
 
Old 08-03-2010, 09:33 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
I don't have much experience with udev personally, but you might be interested in this similar thread that's also active right now.

http://www.linuxquestions.org/questi...evices-822879/

Also, I don't think it's generally a good idea to use ampersands (&) in filenames. It means you have to always quote or escape the name. I suggest renaming your symlink to something else.
 
Old 08-04-2010, 01:18 PM   #3
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
Thanks,

I don't have as serious of a problem as the person in the thread you provided, so I think I can either use the ATTRS{modalias} or the ATTRS{devnum} property in my rules. This is what they now look like:

Code:
KERNELS=="6-2", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", ATTRS{devnum}=="7", SYMLINK="Driver12"
KERNELS=="6-1", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", ATTRS{devnum}=="8", SYMLINK="Driver34"
KERNELS=="7-2", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{devnum}=="4", SYMLINK="HCS12"
can anyone confirm if this is the right approach?
 
Old 08-04-2010, 02:17 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Hi there,

at a glance it looks that you're definitely on the right track; good work.

However, you very well might end up having a similar/related/identical problem as the person in the other thread linked above, if your {devnum} and/or particularly the KERNELS== attributes change sometimes. Without having seen your entire output from when you queried udev for the attributes, I'm guessing that the 6-2 and 6-1 and 7-1 are referring to locations on the root hub, and if it's anything like in that other post, then those could be assigned differently depending upon what's connected at a given time, and upon whichever port/device comes online first.

Your PL2303 device(s) is the same one as in that other post. It's quite possible you'll have problems keeping those two devices straight - UNLESS each serial port is individually connected to a USB port (i.e. is not a 2-in-1 USB-to-serial convertor, but instead it's a single USB-to-serial gadget) and each USB port is on a different root hub inside the computer. Looking at your lsusb output, this does not appear to be the case (it appears that both PL2302 devices are on Bus #6).

Anyhow, you're definitely on the right track! If after a bunch of reboots, your devices are correctly sorted, then great. But if not, then follow the suggestions & course of action that we've been doing in the other thread. The key to definite reliability is to get some guaranteed unique and/or recurring identifier(s) from each gadget, to use in your rules. If you cannot get this, then you're not guaranteed that your devices will be properly distinguished every time.
 
Old 08-04-2010, 03:34 PM   #5
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
Thanks for the tips Celine. I will try to find a common attribute between the ports.
 
Old 08-05-2010, 05:32 PM   #6
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
I should have thought of this a long time ago, but the easiest method by far for figuring this one out is to just get another USB-to-serial adapter, of a different vendor than the other two ports. Now the vendor and product IDs are unique. Simple!
 
Old 08-05-2010, 05:34 PM   #7
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Yes - definitely the most effective/simple way of solving this issue.
The only drawback is that you have to locate and purchase something. But, those things can't cost much huh?
 
Old 08-05-2010, 05:49 PM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Well, that's certainly one way to do it.

But I have one small question I'm curious about. I did a couple of searches on udev and serial devices, and all the examples I saw used something like kernel=="ttyUSB". Where did you get the kernel=="6-2" stuff?
 
Old 08-05-2010, 06:25 PM   #9
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
David,

Have a look at the output of `--attribute-walk` in this post:
http://www.linuxquestions.org/questi...9/#post4049218

Sasha
 
Old 08-05-2010, 11:45 PM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Thanks. Don't know how I missed that before. Still, I'm not sure I understand it completely. I tried searching through my own system for numbers like that and I admit I'm having a hard time matching numbers to physical devices. I'd like to know what command(s) the OP used to find those numbers, and whether there'd be anything more appropriate to use there, like the aforementioned ttyUSB.

But it's not really that important a question, since I don't really need to know it right now. I'm just curious about it.
 
Old 08-06-2010, 11:33 AM   #11
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
Hi David,

I used the following command:

Code:
$ udevadm info -a -p  $(udevadm info -q path -n /dev/ttyUSB0)
This lists all of the parent devices connected to the serial adapter and port. You will see down the list where ATTRS{idVendor} and ATTRS{idProduct} are located, something similar of the name "6-2". It just means the second port of usb6. This will remain constant every time you connect a device to it.

Regards,
Ian
 
Old 08-06-2010, 11:36 AM   #12
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
Just out of curiosity, do you absolutely have to specify a kernel when creating udev rules?
 
Old 08-06-2010, 12:35 PM   #13
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Nope, you don't have to - you just need to specify enough info to be sure that with the info given, your device cannot be mistaken for another device. Here's a couple examples of udev rules I've used for some USB devices I have:
Code:
# Verbatim USB HDD 160 Gib -- see note above re: "RUN+=" as same applies for this drive...
ATTRS{modalias}=="usb:v18A5p0214d0112dc00dsc00dp00ic08isc06ip50",NAME{all_partitions}="usb-verbatim-hdd",GROUP="disk"

# kingston datatraveller 1G usb device: (see note above re: "RUN+=" as same applies for this item..)
SUBSYSTEMS=="usb",ATTRS{manufacturer}=="Kingston",ATTRS{product}=="DataTraveler 2.0",NAME{all_partitions}="usb-kingston",GROUP="plugdev"

# Duracell 16Gib USB flash stick: (see note above re: "RUN+=" as same applies for this item..)
ATTRS{serial}=="001D0F0A94F1B8B1100E03E7",NAME{all_partitions}:="Duracell%n",GROUP:="plugdev"
#SUBSYSTEMS=="usb",ATTRS{idVendor}=="0930",ATTRS{idProduct}=="6545",NAME{all_partitions}:="Duracell%n",GROUP:="plugdev"

# the HP 4-slot 15-in-1 card reader I have now installed in my machine.
SUBSYSTEMS=="scsi",ATTRS{vendor}=="Generic ",ATTRS{model}=="USB SD Reader   ",ATTRS{rev}=="1.00",NAME{all_partitions}="card-reader-SD",GROUP="plugdev"
SUBSYSTEMS=="scsi",ATTRS{vendor}=="Generic ",ATTRS{model}=="USB CF Reader   ",ATTRS{rev}=="1.01",NAME{all_partitions}="card-reader-CF",GROUP="plugdev"
SUBSYSTEMS=="scsi",ATTRS{vendor}=="Generic ",ATTRS{model}=="USB SM Reader   ",ATTRS{rev}=="1.02",NAME{all_partitions}="card-reader-SM",GROUP="plugdev"
SUBSYSTEMS=="scsi",ATTRS{vendor}=="Generic ",ATTRS{model}=="USB MS Reader   ",ATTRS{rev}=="1.03",NAME{all_partitions}="card-reader-MS",GROUP="plugdev"
Note that I'm currently fiddling with the Duracell device, so that rule syntax is possibly a little borked at this monent. But you can see, I haven't used the KERNEL attribute anywhere.
 
Old 08-06-2010, 12:47 PM   #14
ibwood
Member
 
Registered: Jul 2010
Posts: 46

Original Poster
Rep: Reputation: 15
Ok great thanks a lot
 
Old 08-06-2010, 04:46 PM   #15
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Thank you. So you actually started with ttyUSB and dug down from there. I'd probably have figured that out if I had any usb-to-serial devices myself.

I'm not happy with the current default symlinks udev makes for my DVD drives, and I've been toying with the idea of writing up some rules to correct them. This thread has helped me to better understand what I'll need to do to accomplish that. So thanks again, both of you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Writing UDEV rules to get a SCSI scanner working on Ubuntu LXer Syndicated Linux News 1 09-15-2009 12:15 PM
udev not reporting USB vendor or product ID FLLinux Slackware 2 09-09-2009 12:48 PM
Help writing UDEV rules for FC6 jborn Fedora 2 02-23-2007 07:30 PM
writing udev rules doralsoral Linux - Software 10 11-19-2006 03:45 AM
how do i manually load a device with known vendor and product IDs to devices? pyenos Linux - Hardware 0 03-01-2005 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration