USB (PL2303) reliable device names
The USB devices are proliferating on my machine; particularly PL2303 serial port devices. I would like to write a rule so that reliable device names are created using the bus and device numbers for these devices. For example, with the following two devices I would like to see something like /dev/ttyUSB4.4 and /dev/ttyUSB1.5. Could someone give me a hand with this?
Code:
Bus 004 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port |
As often happens, I keep searching and find something that is at least close. I found an example at this webpage and modified it slightly. However, it doesn't separate devices on hubs. Any ideas to fix that?
http://stackoverflow.com/questions/4...er-ubuntu-10-1 File: /etc/udev/rules.d/70-persistent-usb.rules Code:
ACTION=="add", KERNEL=="ttyUSB[0-9]*", PROGRAM="/etc/udev/rules.d/usb-parse-devpath.pm %p", SYMLINK+="ttyUSB%c" Code:
#!/usr/bin/perl -w Added: An example of what it does. I haven't pulled USB0 out and reinserted it since adding the code. Code:
crw-rw---- 1 root dialout 188, 0 May 26 14:13 /dev/ttyUSB0 |
Most of the PL2303 USB serial adapters that I have used have the same attributes and none have serial numbers. The following links will help write a rule based upon the device's port.
http://askubuntu.com/questions/49910...erial-adapters http://stackoverflow.com/questions/4...er-ubuntu-10-1 |
Hi Michael,
I guess you missed my second post. I did finally find both of those pages and came up with the above. Any ideas on what to do about USB hubs? I'm not at that point yet, but it could happen. Added: Hmm, looking at the rule again, it may be a mistake to use the same name. Could a device be reparsed multiple times by the rule? |
The first link shows how to determine the hub.
|
It looks to me like what he did was specific to his needs. I don't understand enough about this to make it generic to all hubs on all the devices. Well, when/if it happens, I'll refer back to this and see if I can figure it out.
|
I finally needed to plug multiple PL2303s into a hub, so I'd like to follow up on this with what I think is a fix. I've made changes to the usb-parse-devpath.pm file so that it handles USB hubs. In my testing, I am using USB Bus 007.
If a PL2303 is plugged directly into USB Bus 7, it will get the usual incremental /dev/ttyUSBx, and there will be a link created: /dev/ttyUSB7-1. However, if a hub is plugged into bus 7, e.g. Code:
Bus 007 Device 101: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB File: /etc/udev/rules.d/usb-parse-devpath.pm Code:
#!/usr/bin/perl -w |
All times are GMT -5. The time now is 07:17 AM. |