0 UDEV rules or how to find your rig at the right port (linux)
Elliott Liggett edytuje tę stronę 2021-05-18 20:28:09 +00:00

Obsolete

For the most up to date information, please visit https://wfview.org/wfview-user-manual/


OLD INFORMATION

USB devices

Depending on when, where and at what sequence you connect them to Linux, you will find that the enumeration changes which is OK for a mouse and keyboard but not well suited if you are going to refer to a device in software.

The following is a way to have fixed names in /dev for the devices.

the key element is that ICOM-transceivers that can be controlled via USB, have the serial number announced when you connect the device to one of the USB ports.

You can use lsusb and it's verbose flag to find out the serial number but a possible easier way is to look here:

roeland@snowpa:~> ls -l /dev/serial/by-id
total 0
lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_IC-9700_13001202_A-if00-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_IC-9700_13001202_B-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001507-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7851_03001140_A-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7851_03001140_B-if00-port0 -> ../../ttyUSB1

a more suitable naming we do use and may be used to auto-detect devices is to use the USB serial number and port and tie them to a persistent name.

Let's dissect the 7300:

lrwxrwxrwx 1 root root 13 Feb  3 19:25 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001507-if00-port0 -> ../../ttyUSB4
                                                                                             ^^^^^^^ ^^^^^^^^
                                                                                                |       |
                                                                         this is the rig's name +       + and the serial

Same is for the 9700, 7610, 785x -- they do have two ports, A and B.

Now to bind a persistent name we can create in /etc/udev/rules.d the file 99-usb-serial.rules:

roeland@snowpa:~> cat /etc/udev/rules.d/99-usb-serial.rules 
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7851 03001140 A", SYMLINK+="IC7851A"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7851 03001140 B", SYMLINK+="IC7851B"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7300 03001507", SYMLINK+="IC7300"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-9700 13001202 A", SYMLINK+="IC9700A"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-9700 13001202 B", SYMLINK+="IC9700B"

this will have the following output in /dev (where the refs to /dev/ttyUSBxx may be different):

roeland@snowpa:~> ls -l /dev/IC*
lrwxrwxrwx 1 root root 7 Feb  3 19:25 /dev/IC7300 -> ttyUSB4
lrwxrwxrwx 1 root root 7 Feb  3 19:25 /dev/IC7851A -> ttyUSB0
lrwxrwxrwx 1 root root 7 Feb  3 19:25 /dev/IC7851B -> ttyUSB1
lrwxrwxrwx 1 root root 7 Feb  3 19:25 /dev/IC9700A -> ttyUSB3
lrwxrwxrwx 1 root root 7 Feb  3 19:25 /dev/IC9700B -> ttyUSB2

effectively this means that if you need the 7300, just use /dev/IC7300 always. Or if you need the 9700, use /dev/IC9700A

If you happen to have multiple same rigs, say two 7300's you could change the SYMLINK part into something like

SYMLINK+="IC7300_1"
SYMLINK+="IC7300_2"

etc.

Please keep the case and start of the rigs always "IC" as the idea is to change the detection code in the future to look for devices in /dev that start with "IC"