Set not1mm's sound card in radio configure

not1mm's voice keyer gets the radio's sound card, named exactly as the
sounddevice library in not1mm's own Python lists it: its settings dialog
finds the device by exact name, and falls back to the first one listed.
PipeWire's name for the card, through PortAudio's JACK support, comes
first, since it stays the same from boot to boot. Without it, or with two
cards of the same name, it's ALSA's, which has the card's number in it;
a number radio wrote before is updated when the card's number changes.

The closing message now leaves only fldigi and POTACAT for you to set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 13:11:16 -07:00
co-authored by Claude Opus 5.5
parent 4053664d77
commit c2cb2bc2f4
5 changed files with 168 additions and 43 deletions
+70 -4
View File
@@ -15,6 +15,7 @@ setup() {
ROOT_HUB="$RADIO_SYSFS/devices/pci0000:00/0000:00:14.0/usb1"
REAL_PYTHON3="$(command -v python3)"
export REAL_PYTHON3
unset XDG_DATA_HOME XDG_CONFIG_HOME UV_TOOL_DIR
# PipeWire's sources and sinks, as `pactl -f json list` prints them: none
# unless a test calls pipewire_card
stub pactl '[ -f "$FAKE_RADIOS/pw-$4" ] && cat "$FAKE_RADIOS/pw-$4" || echo "[]"'
@@ -92,6 +93,18 @@ pipewire_card() {
properties: {"alsa.card": $n, "device.class": "sound"}}]' > "$FAKE_RADIOS/pw-sinks"
}
# The output devices not1mm's sounddevice lists: sd_outputs NAME... Names
# with (hw:...) are ALSA's; the rest are JACK's, except ALSA's pipewire and default
sd_outputs() {
local name
for name; do
case "$name" in
*"(hw:"* | pipewire | default) printf '%s\tALSA\n' "$name" ;;
*) printf '%s\tJACK Audio Connection Kit\n' "$name" ;;
esac
done > "$FAKE_RADIOS/sd-outputs"
}
# The radio on a port answers the probe with ANSWER ("38400 cat_id 0670")
answers() {
echo "$2" > "$FAKE_RADIOS/$1"
@@ -368,7 +381,12 @@ JSON
touch "$HOME/.local/bin/not1mm"
chmod +x "$HOME/.local/bin/not1mm"
mkdir -p "$HOME/.config/not1mm"
echo '{"mycall": "N0CALL", "userigctld": false, "useflrig": false, "usetci": false, "CAT_ip": "127.0.0.1", "CAT_port": 12345}' > "$HOME/.config/not1mm/not1mm.json"
echo '{"mycall": "N0CALL", "userigctld": false, "useflrig": false, "usetci": false, "CAT_ip": "127.0.0.1", "CAT_port": 12345, "sounddevice": "default"}' > "$HOME/.config/not1mm/not1mm.json"
# not1mm's Python, whose sounddevice lists the outputs in $FAKE_RADIOS/sd-outputs
mkdir -p "$HOME/.local/share/uv/tools/not1mm/bin"
printf '#!/bin/bash\ncat "$FAKE_RADIOS/sd-outputs" 2> /dev/null\n' > "$HOME/.local/share/uv/tools/not1mm/bin/python"
chmod +x "$HOME/.local/share/uv/tools/not1mm/bin/python"
sd_outputs "HD-Audio Generic: ALC897 Analog (hw:0,0)" "USB Audio CODEC: USB Audio (hw:1,0)" pipewire default
touch "$FAKE_FLATPAKS/io.github.foldynl.QLog"
qlog_log
touch "$HOME/.local/bin/POTACAT.AppImage" "$HOME/.local/bin/graywolf"
@@ -454,7 +472,7 @@ DIREWOLF_CONF() { echo "$HAMPACK_STATE/conf.d/direwolf.conf"; }
grep -qx "ExecStart=/usr/bin/rigctld -m 3073 -r /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001234-if00-port0 -s 38400 -T 127.0.0.1 -t 4532" "$unit"
grep -qx "systemctl --user enable hampack-rigctld" "$STUB_LOG"
grep -qx "systemctl --user restart hampack-rigctld" "$STUB_LOG"
[[ "$output" == *"PipeWire didn't list the radio's sound card, hw:CARD=CODEC (\"USB Audio CODEC\"), so choose it yourself in WSJT-X, JS8Call, fldigi, not1mm and POTACAT."* ]]
[[ "$output" == *"PipeWire didn't list the radio's sound card, hw:CARD=CODEC (\"USB Audio CODEC\"), so choose it yourself in WSJT-X, JS8Call, fldigi and POTACAT."* ]]
grep -qx "hamlib=3073" "$HAMPACK_STATE/radio"
grep -qx "card=hw:CARD=CODEC" "$HAMPACK_STATE/radio"
}
@@ -684,7 +702,7 @@ DIREWOLF_CONF() { echo "$HAMPACK_STATE/conf.d/direwolf.conf"; }
configurable
jq '.useflrig = true' "$(NOT1MM_JSON)" > "$BATS_TEST_TMPDIR/n.json" && mv "$BATS_TEST_TMPDIR/n.json" "$(NOT1MM_JSON)"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: left alone: it has rig control set up already"* ]]
[[ "$output" == *"not1mm: voice keyer on \"USB Audio CODEC: USB Audio (hw:1,0)\". Left its rig control alone: \`radio configure --force\` replaces it"* ]]
[ "$(jq .useflrig "$(NOT1MM_JSON)")" = true ]
FAKE_RUNNING=not1mm run bash "$REPO/radio" configure --force
@@ -838,7 +856,7 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
[[ "$output" == *"WSJT-X: rig control through rigctld, PTT by CAT, sound card \"USB Audio CODEC Analog Stereo\""* ]]
grep -qx "SoundInName=alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.mono-fallback" "$(WSJTX_INI)"
grep -qx "SoundOutName=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" "$(WSJTX_INI)"
[[ "$output" == *"Choose the radio's sound card yourself in fldigi, not1mm and POTACAT, which name it in ways radio can't: it's \"USB Audio CODEC Analog Stereo\" (hw:CARD=CODEC)."* ]]
[[ "$output" == *"Choose the radio's sound card yourself in fldigi and POTACAT, which name it in ways radio can't: it's \"USB Audio CODEC Analog Stereo\" (hw:CARD=CODEC)."* ]]
run bash "$REPO/radio" configure
[[ "$output" == *"WSJT-X: already set up"* ]]
@@ -912,3 +930,51 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
[[ "$output" == *"Graywolf: skipped: it has no channel that transmits yet"* ]]
[ "$(qlog_query "SELECT COUNT(*) FROM channels" "$(GRAYWOLF_DB)")" = 0 ]
}
@test "configure gives not1mm's voice keyer the radio's sound card by PipeWire's name, which doesn't change" {
configurable
pipewire_card 1
sd_outputs "USB Audio CODEC: USB Audio (hw:1,0)" "USB Audio CODEC Analog Stereo" pipewire default
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: rig control through rigctld, voice keyer on \"USB Audio CODEC Analog Stereo\""* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC Analog Stereo" ]
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: already set up"* ]]
}
@test "configure gives not1mm ALSA's name for the card without PipeWire, or when two cards share its name" {
configurable
run bash "$REPO/radio" configure
[[ "$output" == *"voice keyer on \"USB Audio CODEC: USB Audio (hw:1,0)\""* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC: USB Audio (hw:1,0)" ]
# Two radios with the same codec: PipeWire's name would match both
pipewire_card 1
sd_outputs "USB Audio CODEC: USB Audio (hw:1,0)" "USB Audio CODEC Analog Stereo" "USB Audio CODEC: USB Audio (hw:2,0)" "USB Audio CODEC Analog Stereo"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: already set up"* ]]
}
@test "configure updates not1mm's card when its number changed, and leaves a card you chose unless --force" {
configurable
jq '.sounddevice = "USB Audio CODEC: USB Audio (hw:3,0)"' "$(NOT1MM_JSON)" > "$BATS_TEST_TMPDIR/n.json" && mv "$BATS_TEST_TMPDIR/n.json" "$(NOT1MM_JSON)"
run bash "$REPO/radio" configure
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC: USB Audio (hw:1,0)" ]
jq '.sounddevice = "HD-Audio Generic: ALC897 Analog (hw:0,0)"' "$(NOT1MM_JSON)" > "$BATS_TEST_TMPDIR/n.json" && mv "$BATS_TEST_TMPDIR/n.json" "$(NOT1MM_JSON)"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: Left its sound card (HD-Audio Generic: ALC897 Analog (hw:0,0)) alone"* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "HD-Audio Generic: ALC897 Analog (hw:0,0)" ]
run bash "$REPO/radio" configure --force
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC: USB Audio (hw:1,0)" ]
}
@test "configure says when not1mm's sounddevice doesn't list the radio's card" {
configurable
sd_outputs "HD-Audio Generic: ALC897 Analog (hw:0,0)" pipewire default
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: rig control through rigctld, choose its sound card yourself: its sounddevice library doesn't list the radio's"* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = default ]
}