dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
1500
share rss forum feed

dlsauers

join:2005-10-25
Wellston, OH

USB devices and assigning same tty each time

I have some USB to serial devices, some are standard USB to serial converters, some are the same thing, but they terminate in a special end for certain devices.

What I need to be able to do is assign the SAME SPECIFIC ttyUSBx to the devices. Regardless of what USB port they may be plugged into each time ie: on the laptop, or when the desktop has to be rebooted for some reason

udev rules? ? FAQ or a HOWTO ?

example:

Bus 005 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 005 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
 

Thats on a server with similar devices
Bus 005 Device 002: -> ttyUSB0
Bus 005 Device 003: -> ttyUSB1

On a laptop when these are used in the field for site surveys they could be on any of a number of USB ports on the laptop, I just need the devices to appear on the same ttyUSBx so the code doesn't have to change each time.

Plugging them in a specific order is one option, but I am trying to avoid that on the laptop, and having to unplug one and then replug the other on the desktop in the event of a reboot is also just sort of 20th century. There surely has to be a way to assign x USB ID to x ttyUSBx each time.

Any hints, pointers, ideas, FAQ's, HOWTO's?


koitsu
Premium,MVM
join:2002-07-16
Mountain View, CA
kudos:23
»stackoverflow.com/questions/4800 ··· ntu-10-1

Also potentially useful:

»stackoverflow.com/questions/2530 ··· ing-them

But in general every single thing I've read online points to using a udev rule for this task. Don't ask me how to write one or the details -- I just work here..... :-)


jimkyle
Btrieve Guy
Premium
join:2002-10-20
Oklahoma City, OK
kudos:2
Reviews:
·AT&T Southwest

1 edit

1 recommendation

Here's my /etc/udev/rules.d/70-persistent-net.rules file as an example. You would have some very different details; this file forces my two NIC adapters to have consistent "ethX" device names, based on their MAC addresses. You would need to find a unique identifier for each of your USB devices, and use that to tell which was which, and would need a different file name as well, but it's the same principle.


# PCI device 0x10ec:0x8168 (r8169) -- was WAN now LAN
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0a:cd:18:bb:7f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x11ad:0x0002 (tulip) -- was LAN now WAN
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:a0:cc:db:f0:cf", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


Check out "man 7 udev" to find out about the values passed into a rule. Be prepared for lots of trial and error!

EDIT: Also check out /lib/udev/rules.d for all of the default rules; they can be used as examples once you figure out what, exactly, they do.

--
Jim Kyle


60632649
Premium
join:2003-09-29
New York, NY
reply to dlsauers
Here's the answer that I got from Lenovo on a similar question about USB boot order on... they tried to deflect it to me, but the the answer is that they don't know, it's probably up to the chipset and motherboard manufacturers. The only real way to sort it would be to connect a bunch of usb devices to every port available and watch them try to boot, then fail in a specific order.

I generally come with questions that they can't answer.


No_Strings
Premium,MVM,Ex-Mod 2008-13
join:2001-11-22
The OC
kudos:6

1 recommendation

The question was about device naming, not about boot order.

Uraki
Uraki
Premium
join:2003-06-22
Belle Plaine, KS
reply to dlsauers
This page should help if you are technically inclined:

»www.reactivated.net/writing_udev ··· udevinfo


60632649
Premium
join:2003-09-29
New York, NY
reply to No_Strings
said by No_Strings:

The question was about device naming, not about boot order.

Thanks No_Strings, I can read, that's why I wrote, "similar question," get it?


No_Strings
Premium,MVM,Ex-Mod 2008-13
join:2001-11-22
The OC
kudos:6
No, but I'm sure someone may have a question about USB device boot order and find your post helpful. It's unlikely they will be searching topics on udev rules to find it, though.

Thanks for posting.

mich

join:2008-08-30
reply to dlsauers
This is my rule which gives Atmel AT90USB162 micros a symlink at /dev/at90usb-%k and sets some permissions on it.

m@sauron:/etc/udev/rules.d $ cat 99-dfu.rules 
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffa", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
 

I guess something like this will work for you:
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="$VID1", ATTRS{idProduct}=="$PID1", SYMLINK+="some-device"
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="$VID2", ATTRS{idProduct}=="$PID2", SYMLINK+="other-device"
 

If /etc/udev/rules.d doesn't exist, create it. There is a convention to keep user rules in /etc/udev/rules.d and rules bundled with udev in /lib/udev/rules.d so rules in /etc are less likely to disappear during some update.

You may need to run udevadm --reload (or reboot) to make the new rules work.