Serial Port Management

Linux Configuration

With linux, the user logged in may or may not actually have write-access to the serial port, which is needed in order to run software like wfview. There are also times where it is useful to know which serial devices are connected to radios (or perhaps to which radios).

Basic Serial Port Ownership and Group Membership:

A quick command may be run to temporarly enable full access, however, this is not a good long-term solution as the command must be run every time:

sudo chown $USER /dev/ttyUSB*

A better solution is to modify the current user’s account, adding membership into the group that the system defaults to for serial ports.

First determine the name of the group:

ls -l /dev/ttyUSB*

The group name will be the second name, after the owner’s name. Here is an example output:

eliggett@zep:~$ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 May 2 01:48 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Apr 3 14:38 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Apr 3 14:38 /dev/ttyUSB2

Here, the owner is root and the group owner is “dialout”. On some systems, this might be “modem”.

To append group membership, issue the following command:

sudo usermod -aG dialout $USER

You may need to log out and log back in for this to take effect.

On some systems, you really will need to be the owner of the port, and this depends upon how the system security is configured. In this next section, you’ll have the opportunity to become the default serial port owner.

Using UDEV for nice port names and default ownership:

Linux provides a subsystem called “udev” which, among other things, helps name entries in /dev when devices are connected to the computer. Using a custom udev entry, we can create symlinks to nice device names. For example, on my system, /dev/IC9700 is my IC-9700 serial port, and /dev/IC7300 is my IC-7300 serial port. These names are much easier to remember and to use than their default ttyUSB names, which will have different numbers when you reboot or re-connect a radio.

To do this, we’ll first need to determine the USB device serial number for each radio.

Issue the following command to show the device ids:

ls -l /dev/serial/by-id

You will see output similar to what follows:

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

The part we’re concerned with here isn’t how many nice radios this person has, but rather, the name and serial numbers, for example “IC-7851_03001140_A”. Here, the model is IC-7851, and the serial number is 03001140. Some Icom radios present more than one serial port, and in most cases, we are interested in the “A” port for rig control. The “B” port is for other uses.

Now we need to make a new udev rule. Open up a text document and prepare the text that we will put in. Start with this:

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7851 03001140 A", SYMLINK+="IC7851A", OWNER="eliggett"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7851 03001140 B", SYMLINK+="IC7851B", OWNER="eliggett"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-7300 03001507", SYMLINK+="IC7300", OWNER="eliggett"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-9700 13001202 A", SYMLINK+="IC9700A", OWNER="eliggett"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="IC-9700 13001202 B", SYMLINK+="IC9700B", OWNER="eliggett"

Edit the file so that your serial numbers, model numbers, and username are reflected. Remove any lines for radios you don’t own (yet).

Save the file to /tmp/rules.txt (or any other location you can easily get to)

Now from the terminal, copy the file in to the udev rule location for your system (commonly as shown):

sudo cp /tmp/rules.txt /etc/udev/rules.d/90-persistent-usb.rules

To test it out, disconnect the USB cables from your rigs, and then reconnect. You should now see nice entries in /dev for your radios:

eliggett@zep45:~$ ls -l /dev/IC*
lrwxrwxrwx 1 root root 7 Apr 3 14:38 /dev/IC7300 -> ttyUSB0
lrwxrwxrwx 1 root root 7 Apr 3 14:38 /dev/IC9700 -> ttyUSB1
lrwxrwxrwx 1 root root 7 Apr 3 14:38 /dev/IC9700-data -> ttyUSB2

(Note that I named my “B” port “-data”. You can select whatever you like for yours.)

It’s also worth noting here that when wfview is set up for serial port access (instead of LAN), you can use the –port argument to specify which port you’d like to work with. And thus, one can make desktop shortcuts to each radio like this:

wfview --port /dev/IC7300
 -- or -- 
wfview --port /dev/IC9700

And so on.

pty configuration in Linux (and MacOS)

If you wish to connect other software for digital modes/logging etc. then you will need to use wfview’s built-in pty function. This creates a “virtual” terminal device which you can use in your other software to control wfview as if the software was connected directly to the rig. wfview will also create a symbolic link which you can use as a more readable device name. The default configuration for this is in the settings window under “Virtual Serial Port”. There are a number of default device names that you can use (these are automatically created in your home directory) or you can type the full path to a device name of your choice.

 

Windows Configuration

To connect to your rig via USB, the (USB) serial port will appear in the list of available devices in the Serial Device: combobox. Where your rig has two serial ports (A/B) you must select port A (this is usually the lower numbered of the two. You can use Windows Device Manager to find the correct serial port

Tutorial: Which windows COM port do I pick on JS8Call? – M0IAX