LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   udev: how to rename a device from a usb dongle that creates 3 devices? (https://www.linuxquestions.org/questions/linux-hardware-18/udev-how-to-rename-a-device-from-a-usb-dongle-that-creates-3-devices-4175425017/)

eantoranz 08-31-2012 01:40 PM

udev: how to rename a device from a usb dongle that creates 3 devices?
 
Hi!

I want to rename what in my host is set up as /dev/ttyUSB0 when I plugin my usbdongle to something like: /dev/modemWhatever

I know this is done with udev rules however I want to know how to tell each of the 3 devices from each other.

The device creates 3 ttyUSBx devices: ttyUSB0, 1 and 2.

When I request for information from them to udevadm I see the same information for all of them so I can't really tell which is which.

Code:

$ udevadm info --query=all --path=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0
P: /devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0
E: DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0
E: DEVTYPE=usb_interface
E: DRIVER=option
E: INTERFACE=255/255/255
E: MODALIAS=usb:v12D1p14ACd0000dcEFdsc02dp01icFFiscFFipFF
E: PRODUCT=12d1/14ac/0
E: SUBSYSTEM=usb
E: TYPE=239/2/1
E: UDEV_LOG=3

$ udevadm info --query=all --path=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.3
P: /devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.3
E: DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.3
E: DEVTYPE=usb_interface
E: DRIVER=option
E: INTERFACE=255/255/255
E: MODALIAS=usb:v12D1p14ACd0000dcEFdsc02dp01icFFiscFFipFF
E: PRODUCT=12d1/14ac/0
E: SUBSYSTEM=usb
E: TYPE=239/2/1
E: UDEV_LOG=3

$ udevadm info --query=all --path=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.4
P: /devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.4
E: DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.4
E: DEVTYPE=usb_interface
E: DRIVER=option
E: INTERFACE=255/255/255
E: MODALIAS=usb:v12D1p14ACd0000dcEFdsc02dp01icFFiscFFipFF
E: PRODUCT=12d1/14ac/0
E: SUBSYSTEM=usb
E: TYPE=239/2/1
E: UDEV_LOG=3

Thanks in advance.

David the H. 08-31-2012 05:26 PM

The basic documentation for creating rules can be found here:

http://www.reactivated.net/writing_udev_rules.html

In essence you just need to find something unique about each of the devices to match against, and set up an action for it. I recommend not trying to change the original device name though, just create a symlink to it with the name you want.

If you can't find anything unique, then I don't think it's possible to set up completely-fixed devices for them. From what you've posted so far, it seems that only the device path is different. If they always get created in the same order, perhaps you could use that.

(Full disclosure: I have not yet set up anything like this myself, I've only done a bit of playing around with it.)


All times are GMT -5. The time now is 12:19 PM.