Udev Rules in Linux

I became very frustrated with the fact that my USB ports kept changing. I have a TNC2S 1k2 for Aprs and an SCS Tracker for Robust Packet connected to my Pi. The Icom 7300 is controlled via HamLib on another Raspberry Pi. But once it was necessary to reboot the PI running Linbpq , the ttyUSB0 or the ttyUSB1 would keep changing places. Conclusion, I had to adjust the bpq32.cfg again before everything worked the way I wanted.

Now it is quite easy to do something about this. Call me Lazy because it took so long.

Udev rules look like this

SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303",
SYMLINK+="ttyTNC2S

Now, of course, we first have to find out what the “idVendor” and “idProduct” is.

With the command….

udevadm info -a -n /dev/ttyUSB0

We get a long list of data from usb to serial port ttyUSB0.

With this information we can create an udev rule.

sudo nano etc/udev/rules.d/99-usb-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303",
SYMLINK+="ttyTNC2S
udevadm control --reload
reboot

This has been done for both sides. Both ttyUSB0 and ttyUSB1. And look there are the ttyTNC2S and ttySCS ports. Now you can restart Linux as often as you want and trust that the same USB port is always assigned to the right box.

Now my port config looks like this in bpq32.cfg.

PORT
 PORTNUM=3
 ID=14.1022 RPR ;(RPR)
 TYPE=EXTERNAL 
 COMPORT=/dev/ttySCS
 SPEED=38400
 DRIVER=SCSTracker
 CONFIG
RIGCONTROL
HAMLIB 44.137.31.76:4532
14.1022,USB,F1,H1
****
WL2KREPORT PUBLIC, api.winlink.org, 80, PI8LAP-10, JO11VN, 00-23, 14102200, ROBUST, 25, 35, 3
WL2KREPORT PUBLIC, api.winlink.org, 80, PI8LAP-10, JO11VN, 00-23, 14102200, PKT300, 25, 35, 3
WL2KREPORT PUBLIC, api.winlink.org, 80, PI8LAP-10, JO11VN, 00-23, 144850000, PKT1200, 10, 20, 5, 0
WL2KREPORT PUBLIC, api.winlink.org, 80, PI8LAP-10, JO11VN, 00-23, 430950000, PKT9600, 10, 20, 5, 0
;#
  M UISC
  O 4                   ; MAXFRAME
  F 190                 ; FRACK
  T 8                   ; TX Delay
  FORCE ROBUST
  USEAPPLCALLS          ; Accept connects to all APPLCALLS
  BEACONAFTERSESSION    ; Beacon after session
  %L 1500               ; Centre Freq for Normal Packet (Default is 1500)
  @I 64                 ; Paclen = 60
  %T 1                  ; TX Autotracking 1 = on
  %N 10
  %B 300
ENDPORT

Great…..