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:
co-authored by
Claude Opus 5.5
parent
fee5ce341a
commit
5f15ff3821
@@ -156,3 +156,23 @@ check_radio() {
|
||||
done
|
||||
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
|
||||
}
|
||||
|
||||
@@ -130,6 +130,14 @@ remove() {
|
||||
[ -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" {
|
||||
mark_installed fldigi
|
||||
mkdir -p "$HAMPACK_STATE"
|
||||
|
||||
@@ -16,6 +16,8 @@ setup_fake_home() {
|
||||
# "dep" means it was installed as a dependency
|
||||
export FAKE_PACMAN_DB="$BATS_TEST_TMPDIR/pacman-db"
|
||||
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
|
||||
mkdir -p "$HOME/.local/bin" "$TMPDIR" "$STUB_DIR" "$FAKE_PACMAN_DB" "$FAKE_FLATPAKS"
|
||||
: > "$STUB_LOG"
|
||||
|
||||
@@ -65,6 +65,25 @@ setup() {
|
||||
[ ! -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" {
|
||||
echo "theirs" > "$HOME/.local/bin/radio"
|
||||
run bash "$REPO/update.sh"
|
||||
|
||||
Reference in New Issue
Block a user