Sipsmi's Blog

Techno ramblings of a cynical engineer

Archive for the ‘Amateur Radio’ Category

Multiple FLRig with Persistent Device Mapping

leave a comment »

Multiple FL Rig configurations

So you have multiple transceivers with CAT control being controlled by a single PC (Linux of course); this is easy enough to control with multiple instances of FLRIG as you just start it with:

% flrig --config-dir  /home/mylogin/radio1 (etc)

If you use gnome you can also add launchers with different names such as

/usr/local/share/applications/flrig-radio1.desktop

and make sure you edit to name and pick up the desired configuration:

[Desktop Entry]
Name=Flrigi Radio1
GenericName=Amateur Radio Rig Control
Comment=Amateur Radio Communications
Exec=flrig --config-dir /home/mylogin/radio1
Icon=flrig
Terminal=false
Type=Application
Categories=Network;HamRadio;
Example gnome launcher for multiple instances of FLRIG

USB Device Persistence

The main issue remaining is when you switch USB connectors on in a different order and the serial convertor ones for the CAT appear inconsistently to be /dev/ttyUSB0…N.

Turns out you can use udev rules to map symbolic links to the USB device by looking up vendor and product in the udev rules. I have also added the serial number of the device as I have two USB adaptors on my ICOM with the same chip . USB id for CAT and PTT/Sound. Use lsusb and similar tools to find the vendor, product and serial numbers of your devices.

For instance when I type lsusb fro radio devices I get:

YAESU

Bus 008 Device 007: ID 08bb:29c3 Texas Instruments PCM2903C Audio CODEC
Bus 008 Device 006: ID 10c4:ea70 Silicon Labs CP2105 Dual UART Bridge
Bus 008 Device 005: ID 0424:2512 Microchip Technology, Inc. (formerly SMSC) USB 2.0 Hub

ICOM

Bus 002 Device 022: ID 0d8c:0024 C-Media Electronics, Inc. USB Advanced Audio Device
Bus 002 Device 024: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 002 Device 023: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 002 Device 021: ID 058f:6254 Alcor Micro Corp. USB Hub

and so I created a

/etc/udev/rules.d/50-radios.rules
file as below

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", ATTRS{serial}=="011F4194", SYMLINK+="YAESU", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A4001jMj", SYMLINK+="ICOM1", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A20e1voc", SYMLINK+="ICOM2", MODE="0666" 
Update: After some digging around to see how I can get the two Yaesu ports from the same device with the same serial with distinct SYMLINKs - I found that you could enumerate the "interface number" from teh usb data and allocate to an environment variable -= so the YAESU line above has been replaced by: SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}" SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", ATTRS{serial}=="011F4194", SYMLINK+="YAESU%E{.LOCAL_ifNum}", MODE="0666"

So now when I plug the devices in any order I can use the symlinks /dev/ICOM1 etc in flrig to have a persistent device irrespective of when/where this was mapped. Currently, these look like this:

lrwxrwxrwx 1 root root 7 Dec 13 16:46 /dev/ICOM1 -> ttyUSB4
lrwxrwxrwx 1 root root 7 Dec 13 16:46 /dev/ICOM2 -> ttyUSB5
lrwxrwxrwx 1 root root 7 Dec 13 08:28 /dev/YAESU00 -> ttyUSB1
lrwxrwxrwx 1 root root 7 Dec 13 08:28 /dev/YAESU01 -> ttyUSB2

So essentially, as long as you use the symbolic link it matters not what ttyUSB number the device is mapped to.
Remember to restart the udev service to pick up the new rules ( or reboot ).

udevadm control --reload-rules && udevadm trigger

Disclaimer: This code is
from a hardware engineer turned hacker, it most likely aint pretty, it
most likely can be done better but …. it works

Written by sipsmi

December 13, 2022 at 4:54 pm