Let you key a radio through a CM108 sound card's PTT line

Dire Wolf, Graywolf and others key a radio through a CM108-family sound
card (a Digirig, an AIOC) by setting a GPIO pin through its hidraw
device, which only root can open otherwise. Dire Wolf's own rule gives
it to the audio group, which most Arch users aren't in, and shouldn't
need to be. udev/70-hampack-cm108.rules tags those devices uaccess
instead, so whoever is at the desktop can use them, as they can the
sound card. It matches the devices Dire Wolf 1.8 treats as
CM108-compatible, and no other C-Media devices.

update.sh installs it in /etc/udev/rules.d when it changes, and reloads
and re-applies udev's rules; hampackremove removes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 13:54:42 -07:00
co-authored by Claude Opus 5.5
parent fee5ce341a
commit 5f15ff3821
10 changed files with 112 additions and 4 deletions
+4 -3
View File
@@ -15,9 +15,10 @@ control a radio, with rigctld started when the radio is plugged in.
- [ ] Tell Elecraft's radios apart. The K3, KX3, KX2 and K4 all answer `ID017;`, - [ ] Tell Elecraft's radios apart. The K3, KX3, KX2 and K4 all answer `ID017;`,
so `radio` lists all four. Find an Elecraft command whose reply names so `radio` lists all four. Find an Elecraft command whose reply names
the model the model
- [ ] PTT through a CM108 sound card (Digirig, AIOC, SignaLink-style - [ ] Use PTT through a CM108 sound card in `radio configure` for an
interfaces): a udev rule so you can open its `hidraw` device, for interface whose radio has no CAT (a Digirig or AIOC on a handheld):
Dire Wolf and others Dire Wolf's `PTT CM108`, Graywolf's cm108 method. HamPack's udev rule
already lets you open the card's `hidraw` device
- [ ] Check that the WSJT-X and QLog Flatpaks can open serial ports - [ ] Check that the WSJT-X and QLog Flatpaks can open serial ports
(`--device=all`), in `hampackcheck` or the smoketest (`--device=all`), in `hampackcheck` or the smoketest
- [ ] List USB sound cards with no serial port (SignaLink USB, VOX-keyed - [ ] List USB sound cards with no serial port (SignaLink USB, VOX-keyed
+1 -1
View File
@@ -61,7 +61,7 @@ Graywolf's web UI is at http://localhost:8080 and, by default, can only be reach
`radio` lists the radios plugged into USB: each one's serial port, the sound card that came with it, and its model and Hamlib model number when it recognises it. Most Icoms are recognised from their USB serial number alone. For other radios, run `radio detect --probe`. This asks each one what it is (the CAT `ID;` command, or Icom's CI-V equivalent) over every serial port no other program is using. `radio probe /dev/ttyUSB0` asks a single port. `radio` lists the radios plugged into USB: each one's serial port, the sound card that came with it, and its model and Hamlib model number when it recognises it. Most Icoms are recognised from their USB serial number alone. For other radios, run `radio detect --probe`. This asks each one what it is (the CAT `ID;` command, or Icom's CI-V equivalent) over every serial port no other program is using. `radio probe /dev/ttyUSB0` asks a single port.
Controlling a radio means opening its serial port, and on Arch only members of the `uucp` group can. HamPack adds you to it when it installs. Log out and back in once afterwards for it to take effect. `hampackremove` takes you out of the group again, unless you were already in it before HamPack. Controlling a radio means opening its serial port, and on Arch only members of the `uucp` group can. Keying a radio through the PTT line on a CM108-family sound card (a Digirig, an AIOC) means opening the card's `hidraw` device, which normally only root can; HamPack installs a udev rule, `/etc/udev/rules.d/70-hampack-cm108.rules`, that lets whoever is logged in at the desktop use it, as they can the sound card. HamPack adds you to it when it installs. Log out and back in once afterwards for it to take effect. `hampackremove` takes you out of the group again, unless you were already in it before HamPack.
Probing opens the port, which raises its DTR and RTS lines for a moment before `radio` drops them. Interfaces that key the transmitter with DTR or RTS may key it briefly, so probe with the radio on a dummy load or an antenna. Probing opens the port, which raises its DTR and RTS lines for a moment before `radio` drops them. Interfaces that key the transmitter with DTR or RTS may key it briefly, so probe with the radio on a dummy load or an antenna.
+17
View File
@@ -132,6 +132,23 @@ Dire Wolf, not1mm, QLog and POTACAT quit:
|------|--------|-------|---------|--------|---------|-----|--------|-----------|--------|------|---------|----------|-------|-------| |------|--------|-------|---------|--------|---------|-----|--------|-----------|--------|------|---------|----------|-------|-------|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
## PTT through a CM108 sound card
With a Digirig, an AIOC or another CM108-family interface plugged in, after
`update` has installed `/etc/udev/rules.d/70-hampack-cm108.rules`:
1. `ls /dev/hidraw*` and `udevadm info /dev/hidrawN` find the interface's
hidraw device (its idVendor is 0d8c, 0c76 or 1209).
2. `getfacl /dev/hidrawN` gives you rw, through an ACL ("user:YOU:rw-"),
without being in the audio group.
3. Dire Wolf's `cm108` tool lists the device with "**" and you can run it
without sudo. With `PTT CM108` in direwolf.conf, a beacon keys the radio.
4. A C-Media USB headset that isn't CM108-compatible gets no ACL.
| Date | Commit | Interface | ACL | Keys the radio | Notes |
|------|--------|-----------|-----|----------------|-------|
| | | | | | |
## Pairing radios with sound cards ## Pairing radios with sound cards
- Two radios plugged in at once: each gets its own sound card. - Two radios plugged in at once: each gets its own sound card.
+7
View File
@@ -266,6 +266,13 @@ if [ -f "$RIGCTLD_UNIT" ]; then
systemctl --user daemon-reload 2> /dev/null systemctl --user daemon-reload 2> /dev/null
fi fi
# The udev rules update.sh installed
UDEV_RULES="${HAMPACK_UDEV_RULES_DIR:-/etc/udev/rules.d}/70-hampack-cm108.rules"
if [ -e "$UDEV_RULES" ]; then
echo "Removing HamPack's udev rules..."
sudo rm -f "$UDEV_RULES" && sudo udevadm control --reload-rules
fi
# The flrig autostart entry `radio configure --flrig` added, marked as HamPack's # The flrig autostart entry `radio configure --flrig` added, marked as HamPack's
FLRIG_AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart/hampack-flrig.desktop" FLRIG_AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart/hampack-flrig.desktop"
if grep -qx 'X-HamPack=radio configure --flrig' "$FLRIG_AUTOSTART" 2> /dev/null; then if grep -qx 'X-HamPack=radio configure --flrig' "$FLRIG_AUTOSTART" 2> /dev/null; then
+20
View File
@@ -156,3 +156,23 @@ check_radio() {
done done
no_problems no_problems
} }
@test "udev rules: udevadm accepts HamPack's, if it's there to ask" {
[ -x /usr/bin/udevadm ] || skip "no udevadm"
/usr/bin/udevadm verify --no-summary "$REPO"/udev/*.rules
}
@test "udev rules: the CM108 rule matches each device Dire Wolf treats as CM108-compatible" {
local rules="$REPO/udev/70-hampack-cm108.rules" device vid pid
for device in 0d8c:0008 0d8c:000f 0d8c:0012 0d8c:0013 0d8c:0139 0d8c:013a 0d8c:013c 0c76:1605 0c76:1607 0c76:160b 1209:7388; do
vid="${device%:*}" pid="${device#*:}"
grep "ATTRS{idVendor}==\"$vid\"" "$rules" | grep -oE 'idProduct}=="[^"]+"' | cut -d'"' -f2 | tr '|' '\n' |
while read -r pattern; do [[ "$pid" == $pattern ]] && echo match; done | grep -q match ||
PROBLEMS+=("$device isn't matched")
done
# and not other C-Media devices, such as headsets
grep "0d8c" "$rules" | grep -oE 'idProduct}=="[^"]+"' | cut -d'"' -f2 | tr '|' '\n' |
while read -r pattern; do [[ 0014 == $pattern || 0001 == $pattern ]] && echo "matches 0014 or 0001"; done | grep -q . &&
PROBLEMS+=("matches C-Media devices that aren't CM108-compatible")
no_problems
}
+8
View File
@@ -130,6 +130,14 @@ remove() {
[ -e "$HOME/.config/autostart/my-flrig.desktop" ] [ -e "$HOME/.config/autostart/my-flrig.desktop" ]
} }
@test "removes HamPack's udev rule" {
mkdir -p "$HAMPACK_UDEV_RULES_DIR"
echo rule > "$HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules"
remove
[ "$status" -eq 0 ]
grep -qx "sudo rm -f $HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules" "$STUB_LOG"
}
@test "does nothing unless confirmed" { @test "does nothing unless confirmed" {
mark_installed fldigi mark_installed fldigi
mkdir -p "$HAMPACK_STATE" mkdir -p "$HAMPACK_STATE"
+2
View File
@@ -16,6 +16,8 @@ setup_fake_home() {
# "dep" means it was installed as a dependency # "dep" means it was installed as a dependency
export FAKE_PACMAN_DB="$BATS_TEST_TMPDIR/pacman-db" export FAKE_PACMAN_DB="$BATS_TEST_TMPDIR/pacman-db"
export FAKE_FLATPAKS="$BATS_TEST_TMPDIR/flatpaks" export FAKE_FLATPAKS="$BATS_TEST_TMPDIR/flatpaks"
# Where update.sh installs udev rules
export HAMPACK_UDEV_RULES_DIR="$BATS_TEST_TMPDIR/udev-rules"
unset DISPLAY WAYLAND_DISPLAY WINEPREFIX HAMPACK_SKIP_WINDOWS_APPS unset DISPLAY WAYLAND_DISPLAY WINEPREFIX HAMPACK_SKIP_WINDOWS_APPS
mkdir -p "$HOME/.local/bin" "$TMPDIR" "$STUB_DIR" "$FAKE_PACMAN_DB" "$FAKE_FLATPAKS" mkdir -p "$HOME/.local/bin" "$TMPDIR" "$STUB_DIR" "$FAKE_PACMAN_DB" "$FAKE_FLATPAKS"
: > "$STUB_LOG" : > "$STUB_LOG"
+19
View File
@@ -65,6 +65,25 @@ setup() {
[ ! -e "$HAMPACK_STATE/added-groups" ] [ ! -e "$HAMPACK_STATE/added-groups" ]
} }
@test "installs the CM108 udev rule once, and again when it changes" {
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
grep -qx "sudo install -m 644 $REPO/udev/70-hampack-cm108.rules $HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules" "$STUB_LOG"
grep -qx "udevadm control --reload-rules" "$STUB_LOG"
grep -qx "udevadm trigger --subsystem-match=hidraw --action=change" "$STUB_LOG"
# Installed as it is now: nothing to do
mkdir -p "$HAMPACK_UDEV_RULES_DIR"
cp "$REPO/udev/70-hampack-cm108.rules" "$HAMPACK_UDEV_RULES_DIR/"
: > "$STUB_LOG"
run bash "$REPO/update.sh"
! grep -q "70-hampack-cm108" "$STUB_LOG"
echo "# older" >> "$HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules"
run bash "$REPO/update.sh"
grep -q "^sudo install -m 644 .*70-hampack-cm108.rules" "$STUB_LOG"
}
@test "update leaves alone a radio command that isn't HamPack's" { @test "update leaves alone a radio command that isn't HamPack's" {
echo "theirs" > "$HOME/.local/bin/radio" echo "theirs" > "$HOME/.local/bin/radio"
run bash "$REPO/update.sh" run bash "$REPO/update.sh"
+21
View File
@@ -0,0 +1,21 @@
# Lets you key a radio through the PTT line on a CM108-family USB sound card
# (a Digirig, an AIOC, many homemade interfaces), from Dire Wolf, Graywolf
# and other programs. They set a GPIO pin on the sound card through its
# hidraw device, which only root can open otherwise. "uaccess" gives the
# person logged in at the desktop access to it, as they have to the sound
# card itself, without joining the audio group.
#
# The devices are those Dire Wolf 1.8 treats as CM108-compatible (its
# cm108.c GOOD_DEVICE). Installed by HamPack's update.sh, removed by
# hampackremove. Numbered below 73 so uaccess is set before
# 73-seat-late.rules applies it.
# C-Media CM108, CM109, CM119 (0008-000f), CM108B (0012), CM119B (0013),
# CM108AH (0139), CM119A (013a), CM108AH and HS100 (013c)
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="000[89a-f]|0012|0013|0139|013a|013c", TAG+="uaccess"
# SSS1621 and SSS1623
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0c76", ATTRS{idProduct}=="1605|1607|160b", TAG+="uaccess"
# AIOC (All-In-One Cable)
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7388", TAG+="uaccess"
+13
View File
@@ -90,6 +90,18 @@ join_serial_group() {
echo " Added you to the uucp group, so programs can control your radio. Log out and back in for it to take effect." echo " Added you to the uucp group, so programs can control your radio. Log out and back in for it to take effect."
} }
# Let you key a radio through a CM108-family sound card's PTT pin (Digirig,
# AIOC), which programs reach through its hidraw device. Reinstalled when
# udev/70-hampack-cm108.rules changes
install_udev_rules() {
local rules="${HAMPACK_UDEV_RULES_DIR:-/etc/udev/rules.d}/70-hampack-cm108.rules"
cmp -s "$SELF/udev/70-hampack-cm108.rules" "$rules" && return 0
echo "Installing $rules..."
sudo install -m 644 "$SELF/udev/70-hampack-cm108.rules" "$rules" &&
sudo udevadm control --reload-rules &&
sudo udevadm trigger --subsystem-match=hidraw --action=change
}
# Install the packages in packages.conf, and record the ones that weren't # Install the packages in packages.conf, and record the ones that weren't
# already installed, so hampackremove removes those and nothing the user had before # already installed, so hampackremove removes those and nothing the user had before
install_hampack_packages() { install_hampack_packages() {
@@ -164,6 +176,7 @@ fi
step "Removing stale HamPack files" remove_stale_files step "Removing stale HamPack files" remove_stale_files
step "Installing HamPack tools" install_tools step "Installing HamPack tools" install_tools
step "Adding you to the uucp group, for radios' serial ports" join_serial_group step "Adding you to the uucp group, for radios' serial ports" join_serial_group
step "Installing udev rules, for PTT through a CM108 sound card" install_udev_rules
step "Installing HamPack packages" install_hampack_packages step "Installing HamPack packages" install_hampack_packages
step "Installing Flatpak applications" bash "$SELF/install-flatpaks.sh" step "Installing Flatpak applications" bash "$SELF/install-flatpaks.sh"
step "Installing pre-built binaries" bash "$SELF/install-binaries.sh" step "Installing pre-built binaries" bash "$SELF/install-binaries.sh"