Linux – Wandering USB devices

As I detailed in my QO-100 Satellite Ground Station Complete Build article I use a Griffin Powermate VFO knob to control the receive VFO frequency when in split mode or needing to RIT a DX station to get on frequency with them. Since building the ground station this setup has worked perfectly and without error however, for the last couple of days every time I start my Kubuntu Linux PC the USB VFO knob appears on a different USB event queue.

For the last two years the VFO knob has always appeared on /dev/input/event11 but, after connecting a Pluto+ SDR transceiver to the PC via USB the VFO knob now appears randomly on the /dev/input/events tree. This normally doesn’t cause any problems but, my Node-Red QO-100 Ground Station Control Dashboard expects the device to always be on /dev/input/event11.

Griffin Technology Powermate VFO
Griffin Technology Powermate VFO

Initially I tried to find a way to lock the USB VFO knob to /dev/input/event11 however, there doesn’t appear to be a way to do this as the event tree is built at boot time by udev.

Digging deeper into udev I discovered that it’s possible to create a udev rule that is read at boot time, that will search for the device and then create a symlink to it with the same name each time making the USB VFO Knob appear as if it’s always in the same place. This is exactly what I need so I set about writing the udev rule.

To find out what event the USB VFO knob is currently on I ran evtest on the Linux command-line and got the following output.

No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Sleep Button
/dev/input/event1:      Power Button
/dev/input/event2:      Power Button
/dev/input/event3:      Video Bus
/dev/input/event4:      Telink Wireless Receiver Mouse
/dev/input/event5:      Telink Wireless Receiver Consumer Control
/dev/input/event6:      Telink Wireless Receiver System Control
/dev/input/event7:      Telink Wireless Receiver
/dev/input/event8:      Kensington USB/PS2 Orbit
/dev/input/event9:      PixArt USB Optical Mouse
/dev/input/event10:     USB PnP Audio Device
/dev/input/event11:     HDA Intel PCH Front Mic
/dev/input/event12:     HDA Intel PCH Rear Mic
/dev/input/event13:     HDA Intel PCH Line
/dev/input/event14:     HDA Intel PCH Line Out Front
/dev/input/event15:     HDA Intel PCH Line Out Surround
/dev/input/event16:     HDA Intel PCH Line Out CLFE
/dev/input/event17:     HDA Intel PCH Line Out Side
/dev/input/event18:     HDA Intel PCH Front Headphone
/dev/input/event19:     HDA Intel PCH HDMI/DP,pcm=3
/dev/input/event20:     HDA Intel PCH HDMI/DP,pcm=7
/dev/input/event21:     HDA Intel PCH HDMI/DP,pcm=8
/dev/input/event22:     HDA Intel PCH HDMI/DP,pcm=9
/dev/input/event23:     HDA Intel PCH HDMI/DP,pcm=10
/dev/input/event24:     Griffin PowerMate
/dev/input/event25:     Realtek RTL2832U reference design

This shows that currently the Griffin Powermate VFO knob is on event 24.

Having this information I now needed to use the udevadm command to obtain the Vendor and Product ID of the USB VFO knob.

udevadm info -a /dev/input/event24

This returns a lot of information about the USB device, more than I was expecting but, upon close inspection I found the Vendor and Product IDs.

ATTRS{id/product}=="0410"
ATTRS{id/vendor}=="077d"

Now that I have the Vendor and Product IDs I could start writing the udev rule.

Using the vi text editor on the command-line I created the necessary file in the
/etc/udev/rules.d/ directory.rule

vi /etc/udev/rules.d/90-powermate.rules

Into the file I wrote the following udev rule.

SUBSYSTEMS=="input", ATTRS{id/product}=="0410", ATTRS{id/vendor}=="077d", SYMLINK += "powermate"

Note: That should all be on one line in the file not wrapped as shown above.

This one line rule sets the subsystem to input events, sets the Product and Vendor IDs to that of the Griffin Powermate USB VFO knob and then creates the symlink /dev/powermate

Once I’d completed the rule, I saved the file and exited the vi text editor.

Next I needed to use udevadm to get it to re-read the udev rules as if it were boot time and check that it created the symlink.

udevadm control -R

Once the udevadm command completed I used the ls command to see if the symlink had been created.

ls -la /dev/powermate
lrwxrwxrwx 1 root root 13 Jul  3 15:32 /dev/powermate -> input/event24

As shown above the symlink had been created and I could now enter
/dev/powermate into my Node-Red code so that it always finds the VFO knob regardless of what event number it appears on.

Just to make sure it worked correctly at boot time, I shutdown my Kubuntu linux PC and started it from a cold boot. Sure enough the
/dev/powermate symlink was created and pointed to the new event number in the /dev/input tree, problem solved!

I hope this information is useful to Linux users especially as it can be used for any USB input device.

It’s worth noting that you will need to be root user to run most of the commands or use sudo from your regular user account.

More soon ….

UPDATE: QO-100 Node Red Dashboard

I’ve been making a few improvements to my QO-100 Node Red Dashboard whilst waiting for the 2.4Ghz hardware to arrive. I’ve added the ability to split the RX and TX VFOs so that I can tune away from the TX frequency for working split stations or for tuning to slightly off frequency stations. I also added a series of tuning buttons to the top of the GQRX side of the dashboard to enable easy tuning using the trackball connected to my Kubuntu PC. This worked well but, I really missed having a real VFO knob like a conventional radio.

As I had a Griffin Powewrmate USB VFO from a previous SDR radio I added it to the flow as well so that I had a physical VFO knob for the SDR receiver. Details on how I got it working using evtest and a simple BASH script are in the Griffin Powermate article.

M0AWS QO-100 Node Red Dashboard Flow
M0AWS QO-100 Node Red Dashboard Flow

The Node Red flow is looking a little busier with the addition of split mode and the Griffin Powermate USB VFO which has really enhanced the useability of the solution. It’s very impressive what can be achieved with Node Red with a little imagination. You really don’t need to be a heavy weight programmer to make things work.

M0AWS QO-100 Node Red Dashboard as of 07/06/23
M0AWS QO-100 Node Red Dashboard as of 07/06/23

I also put together some code to calculate the S Meter reading from the dBFS data the GQRX SDR software generates. It’s not 100% accurate but, it’s close enough to be useful.

On the IC-705 side of the Dashboard I also now display the 2.4Ghz uplink frequency so that it’s available for logging.

So with the QO-100 Dashboard ready to go live I have now started putting together the 2.4Ghz transmit path of the ground station. I have the 2.4Ghz transverter and matching 12w amplifier from DXPatrol, the IceCone Helix 2.4Ghz antenna from Nolle Engineering, some LMR-400-UF and connectors from Barenco and an appropriate water proof enclosure from Screwfix to fit all the kit into however, I’m now being held up by one simple little SMA male to SMA male connector that I need to connect the transverter and amp together.

The SMA connector has been ordered but, is taking a month of Sundays to arrive! Hopefully it’ll arrive soon and I’ll finally get on the QO-100 satellite and start enjoying the fun.

More soon …

Use a Griffin Powermate with SDR via Node Red

I’ve been gradually building my QO-100 ground station over the last few months and have had the receive path working for some time now. One of the things I really miss with the Funcube Dongle Pro+ (FCD) SDR is a real VFO knob for changing frequency.

My QO-100 Node Red dashboard is configured so that I can have the FCD track the uplink frequency from the IC-705 but, sometimes I use the FCD without the IC-705 in the shack and so a physical VFO would be handy.

Many years ago when I lived in France (F5VKM) I had a Flexradio Flex-3000 SDR, a great radio in it’s time and one that gave me many hours of enjoyment. One addition I bought for that station was a Griffin Technology Powermate VFO knob. It worked extremely well with the PowerSDR software for the Flex-3000 and I used it for many years.

Many years later I’m back in the UK and much of my equipment is packed away in the attic, including the Griffin Technology Powermate VFO.

I decided to dig it out and see if I could get it working with GQRX SDR software. Sadly I couldn’t get it working with GQRX however, I did find a way of getting it working with Node Red and thus could add it to my QO-100 Node Red Dashboard and then control GQRX with it via a simple Node Red flow.

Griffin Technology Powermate VFO
Griffin Technology Powermate VFO

Plugging the Powermate VFO into my Kubuntu PC it wasn’t immediately recognised by the Linux O/S. After a little searching I found the driver on Github. I added the PPA to my aptitude sources and installed the driver using apt.

https://launchpad.net/~stefansundin/+archive/ubuntu/powermate

Once installed the default config for the Powermate device is to control the default audio device volume. To make the device available for use as a VFO knob you need to change the configuration so that the default setting is disabled. To do this is relatively easy, just edit the config file using your favourite command line editor (Vi/Vim in my case) and add the following entry.

vi /etc/powermate.toml

# Entry to control HDMI volume with Powermate
#sink_name = "alsa_output.pci-0000_01_00.1.hdmi-stereo"

# Set powermate not to work with volume control
sink_name = ""

As shown above, comment out the default “sink_name” entry (Yours may be different depending on audio device in your PC) and add in the Powermate “sink_name” entry that effectively assigns it to nothing.

Once this is done, save the file and exit your editor and then reboot the PC.

Next you’ll need to install a small program called evtest.

sudo apt install evtest

To check the evtest program has installed correctly, plugin your Powermate VFO to any available USB port and run the following command in a terminal.

evtest /dev/input/powermate

Turning the Powermate knob you should see output on the screen showing the input from the device. You should also see BTN events for each press of the Powermate device.

Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x77d product 0x410 version 0x400
Input device name: "Griffin PowerMate"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 256 (BTN_0)
  Event type 2 (EV_REL)
    Event code 7 (REL_DIAL)
  Event type 4 (EV_MSC)
    Event code 1 (MSC_PULSELED)
Properties:
Testing ... (interrupt to exit)
Event: time 1685816662.086666, type 2 (EV_REL), code 7 (REL_DIAL), value -1
Event: time 1685816662.086666, -------------- SYN_REPORT ------------
Event: time 1685816662.318638, type 2 (EV_REL), code 7 (REL_DIAL), value -1
Event: time 1685816662.318638, -------------- SYN_REPORT ------------
Event: time 1685816662.574615, type 2 (EV_REL), code 7 (REL_DIAL), value -1
Event: time 1685816662.574615, -------------- SYN_REPORT ------------
Event: time 1685816663.670461, type 2 (EV_REL), code 7 (REL_DIAL), value 1
Event: time 1685816663.670461, -------------- SYN_REPORT ------------
Event: time 1685816664.030421, type 2 (EV_REL), code 7 (REL_DIAL), value 1
Event: time 1685816664.030421, -------------- SYN_REPORT ------------
Event: time 1685816664.334389, type 2 (EV_REL), code 7 (REL_DIAL), value 1
Event: time 1685816664.334389, -------------- SYN_REPORT ------------
Event: time 1685816665.334255, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1685816665.334255, -------------- SYN_REPORT ------------
Event: time 1685816665.558230, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1685816665.558230, -------------- SYN_REPORT ------------
Event: time 1685816666.030161, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1685816666.030161, -------------- SYN_REPORT ------------
Event: time 1685816666.182151, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1685816666.182151, -------------- SYN_REPORT ------------

At this point you’re ready to stop evtest (CTRL-C) and then create the following little BASH shell script that Node Red will run to collect the O/P from the Powermate USB device.

#!/bin/bash

###############################################
# Griffin Technology Powermate control script #
# for Node Red.                               #
#                                             #
# 04/06/23 - M0AWS - v0.1                     #
#                                             #
###############################################

VAL="1"
echo "STEP-1Hz"

/usr/bin/evtest /dev/input/powermate | while read LINE 
do
   case $LINE in

      *"(REL_DIAL), value 1") echo "$VAL"
           ;;

      *"(REL_DIAL), value -1") echo "-$VAL"
           ;;

      *"(BTN_0), value 1") case $VAL in

                              "1") VAL="10"
                                   echo "STEP-10Hz"
                                      ;;

                             "10") VAL="100"
                                   echo "STEP-100Hz"
                                      ;;

                             "100") VAL="1000"
                                    echo "STEP-1Khz"
                                       ;;

                             "1000") VAL="10000"
                                     echo "STEP-10Khz"
                                         ;;

                             "10000") VAL="1"
                                       echo "STEP-1Hz"
                                          ;;
                              esac
                                 ;;
        esac
done

Once the BASH script is copied and pasted into a file called powermate.sh you need to make it executable by using the following command.

chmod 700 ./powermate.sh

If you now run the shell script in a terminal you’ll see a similar output to that shown below from the device when used.

./powermate.sh 
STEP-1Hz
-1
-1
-1
1
1
1
STEP-10Hz
10
10
10
-10
-10
-10
STEP-100Hz
100
-100
-100
STEP-1Khz
1000
STEP-10Khz
STEP-1Hz
1
1
STEP-10Hz

As you can see above the shell script outputs a positive or negative number for VFO tuning and changes the VFO step size each time the Powermate is depressed.

Getting this output from the BASH shell script into Node Red is really simple to achieve using just 3 or 4 nodes.

In the Node Red development UI create the following nodes.

Griffin Powermate Node Red Nodes
Griffin Powermate Node Red Nodes

The first node in the flow is a simple inject node, here I called it trigger. This sends a timestamp into the next node in the flow at startup to set the flow running.

The Griffin Powermate node is a simple exec node that runs the script we created above.

M0AWS Powermate exec node
M0AWS Powermate exec node

Configure the node as shown above and connect it to the inject node that’s used as a trigger. Note: Change “user” in the Command field shown above to that of your username on your Linux PC)

Once done create the third node in the flow, a simple switch node and configure as shown below.

Switch Node for Powermate
Switch Node for Powermate

The switch node has two outputs, the top one is a text output that is fed into a text field to show the current step size of the Powermate device and the lower output is the numeric output that must be fed into your VFO control flow so that the VFO value is incremented/decremented by the amount output by the Powermate device.

I’ve found the Griffin Technology Powermate USB device works extremely well with Node Red and GQRX that I use for controlling the FCD SDR radio and it’s now part of my QO-100 ground station build.

M0AWS QO-100 Dashboard with Powermate Step Display at bottom
M0AWS QO-100 Dashboard with Powermate Step Display at bottom

As shown above you can see the Powermate Step size at the bottom of the dashboard, this text changes each time the Powermate device is depressed and will set a step size of 1Hz, 10Hz, 100Hz, 1Khz, 10Khz in a round-robin fashion.

The next stage of the build is the 2.4Ghz transmit path. I now have all the necessary hardware and so this part of the build can finally commence.

More soon …