Set the radio's sound card in radio configure
WSJT-X and JS8Call get the radio's sound card as PipeWire names it: radio
asks pactl for the input and output nodes on the radio's ALSA card.
WSJT-X (Qt 5, through Qt's PulseAudio plugin) keeps the node names in
SoundInName and SoundOutName; JS8Call (Qt 6) keeps them in SoundInId and
SoundOutId, with PipeWire's descriptions, quoted as Qt writes them, in
SoundInName and SoundOutName. A setting that's empty or a default
("default", "pipewire") is replaced; a device you chose is left alone
unless --force.
If Graywolf has no channels, it gets input and output devices on
plughw:CARD=...,DEV=0 and a channel named after the radio, with its
defaults (1200 baud AFSK, APRS) and PTT through rigctld, in the same
stop and start as the PTT change.
fldigi, not1mm and POTACAT name sound cards in ways radio can't write,
so the closing message names them and says which card to choose.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
04d973039a
commit
4053664d77
+112
-3
@@ -15,6 +15,9 @@ setup() {
|
||||
ROOT_HUB="$RADIO_SYSFS/devices/pci0000:00/0000:00:14.0/usb1"
|
||||
REAL_PYTHON3="$(command -v python3)"
|
||||
export REAL_PYTHON3
|
||||
# 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 "[]"'
|
||||
mkdir -p "$ROOT_HUB" "$RADIO_SYSFS/class/tty" "$RADIO_SYSFS/class/sound" \
|
||||
"$RADIO_DEV/serial/by-id" "$RADIO_PROC" "$RADIO_LOCKDIR" "$FAKE_RADIOS"
|
||||
}
|
||||
@@ -73,6 +76,22 @@ yaesu() {
|
||||
card "$1/$1.2" "${5:-card1}" "${6:-CODEC}"
|
||||
}
|
||||
|
||||
# PipeWire lists ALSA card NUMBER as a USB codec, with a monitor source
|
||||
# first, as PipeWire lists them: pipewire_card NUMBER [DESCRIPTION]
|
||||
pipewire_card() {
|
||||
local desc="${2:-USB Audio CODEC}"
|
||||
jq -n --arg n "$1" --arg desc "$desc" '[
|
||||
{name: "alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor", description: ("Monitor of " + $desc + " Analog Stereo"),
|
||||
properties: {"alsa.card": $n, "device.class": "monitor"}},
|
||||
{name: "alsa_input.pci-0000_00_1f.3.analog-stereo", description: "Built-in Audio Analog Stereo",
|
||||
properties: {"alsa.card": "0", "device.class": "sound"}},
|
||||
{name: "alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.mono-fallback", description: ($desc + " Mono"),
|
||||
properties: {"alsa.card": $n, "device.class": "sound"}}]' > "$FAKE_RADIOS/pw-sources"
|
||||
jq -n --arg n "$1" --arg desc "$desc" '[
|
||||
{name: "alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo", description: ($desc + " Analog Stereo"),
|
||||
properties: {"alsa.card": $n, "device.class": "sound"}}]' > "$FAKE_RADIOS/pw-sinks"
|
||||
}
|
||||
|
||||
# The radio on a port answers the probe with ANSWER ("38400 cat_id 0670")
|
||||
answers() {
|
||||
echo "$2" > "$FAKE_RADIOS/$1"
|
||||
@@ -401,8 +420,13 @@ graywolf_db() {
|
||||
import sqlite3, sys
|
||||
con = sqlite3.connect(sys.argv[1])
|
||||
con.execute("PRAGMA journal_mode = WAL")
|
||||
con.execute("CREATE TABLE audio_devices (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, direction TEXT NOT NULL DEFAULT 'input', "
|
||||
"source_type TEXT NOT NULL, source_path TEXT, sample_rate INTEGER NOT NULL DEFAULT 48000, channels INTEGER NOT NULL DEFAULT 1, "
|
||||
"format TEXT NOT NULL DEFAULT 's16le', gain_db REAL NOT NULL DEFAULT 0, created_at DATETIME, updated_at DATETIME)")
|
||||
con.execute("CREATE TABLE channels (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, input_device_id INTEGER, "
|
||||
"input_channel INTEGER NOT NULL DEFAULT 0, output_device_id INTEGER NOT NULL DEFAULT 0, enabled NUMERIC NOT NULL DEFAULT true)")
|
||||
"input_channel INTEGER NOT NULL DEFAULT 0, output_device_id INTEGER NOT NULL DEFAULT 0, output_channel INTEGER NOT NULL DEFAULT 0, "
|
||||
"modem_type TEXT NOT NULL DEFAULT 'afsk', bit_rate INTEGER NOT NULL DEFAULT 1200, mode TEXT NOT NULL DEFAULT 'aprs', "
|
||||
"created_at DATETIME, updated_at DATETIME, enabled NUMERIC NOT NULL DEFAULT true)")
|
||||
con.execute("CREATE TABLE ptt_configs (id INTEGER PRIMARY KEY AUTOINCREMENT, channel_id INTEGER NOT NULL UNIQUE, "
|
||||
"method TEXT NOT NULL DEFAULT 'none', device TEXT, gpio_pin INTEGER, ptt_method INTEGER NOT NULL DEFAULT 0, "
|
||||
"gpio_line INTEGER NOT NULL DEFAULT 0, invert NUMERIC NOT NULL DEFAULT false, slot_time_ms INTEGER NOT NULL DEFAULT 10, "
|
||||
@@ -430,7 +454,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" == *"Choose the radio's sound card in the other programs yourself: hw:CARD=CODEC, \"USB Audio CODEC\""* ]]
|
||||
[[ "$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."* ]]
|
||||
grep -qx "hamlib=3073" "$HAMPACK_STATE/radio"
|
||||
grep -qx "card=hw:CARD=CODEC" "$HAMPACK_STATE/radio"
|
||||
}
|
||||
@@ -483,7 +507,7 @@ DIREWOLF_CONF() { echo "$HAMPACK_STATE/conf.d/direwolf.conf"; }
|
||||
printf '[Configuration]\nRig=Yaesu FT-991\nCATSerialPort=/dev/ttyUSB3\n' > "$(mkdir -p "$(dirname "$(WSJTX_INI)")"; WSJTX_INI)"
|
||||
run bash "$REPO/radio" configure
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"WSJT-X: left alone: it's set up for Yaesu FT-991. \`radio configure --force\` replaces that"* ]]
|
||||
[[ "$output" == *"WSJT-X: Left its rig (Yaesu FT-991) alone: \`radio configure --force\` replaces it"* ]]
|
||||
grep -qx "Rig=Yaesu FT-991" "$(WSJTX_INI)"
|
||||
|
||||
run bash "$REPO/radio" configure --force
|
||||
@@ -803,3 +827,88 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
|
||||
[[ "$output" == *"Graywolf: skipped: couldn't stop it to change its settings. Instead, in its web UI (http://localhost:8080), set each channel's PTT to rigctld, 127.0.0.1:4532"* ]]
|
||||
[ "$(qlog_query "SELECT COUNT(*) FROM ptt_configs" "$(GRAYWOLF_DB)")" = 0 ]
|
||||
}
|
||||
|
||||
# --- sound cards ---
|
||||
|
||||
@test "configure gives WSJT-X the radio's sound card as PipeWire names it" {
|
||||
configurable
|
||||
pipewire_card 1
|
||||
run bash "$REPO/radio" configure
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$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)."* ]]
|
||||
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"WSJT-X: already set up"* ]]
|
||||
}
|
||||
|
||||
@test "configure gives JS8Call the sound card's PipeWire name and description, quoted as Qt would" {
|
||||
configurable
|
||||
pipewire_card 1 "Radio, USB"
|
||||
run bash "$REPO/radio" configure
|
||||
grep -qx "SoundInId=alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.mono-fallback" "$HOME/.config/JS8Call.ini"
|
||||
grep -qx "SoundOutId=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" "$HOME/.config/JS8Call.ini"
|
||||
grep -qx 'SoundInName="Radio, USB Mono"' "$HOME/.config/JS8Call.ini"
|
||||
grep -qx 'SoundOutName="Radio, USB Analog Stereo"' "$HOME/.config/JS8Call.ini"
|
||||
}
|
||||
|
||||
@test "configure replaces a default sound device, but not one you chose, unless --force" {
|
||||
configurable
|
||||
pipewire_card 1
|
||||
mkdir -p "$(dirname "$(WSJTX_INI)")"
|
||||
printf '[Configuration]\nSoundInName=pipewire\nSoundOutName=pipewire\n' > "$(WSJTX_INI)"
|
||||
run bash "$REPO/radio" configure
|
||||
grep -qx "SoundInName=alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.mono-fallback" "$(WSJTX_INI)"
|
||||
|
||||
printf '[Configuration]\nRig=Hamlib NET rigctl\nCATNetworkPort=127.0.0.1:4532\nSoundInName=alsa_input.usb-Other\nSoundOutName=alsa_output.usb-Other\n' > "$(WSJTX_INI)"
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"WSJT-X: Left its sound card (alsa_input.usb-Other) alone: \`radio configure --force\` replaces it"* ]]
|
||||
grep -qx "SoundInName=alsa_input.usb-Other" "$(WSJTX_INI)"
|
||||
|
||||
run bash "$REPO/radio" configure --force
|
||||
grep -qx "SoundOutName=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" "$(WSJTX_INI)"
|
||||
}
|
||||
|
||||
@test "configure leaves sound devices alone when PipeWire doesn't list the radio's card" {
|
||||
configurable
|
||||
pipewire_card 7
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"WSJT-X: rig control through rigctld, PTT by CAT"$'\n'* ]]
|
||||
! grep -q "^SoundInName=" "$(WSJTX_INI)"
|
||||
[[ "$output" == *"PipeWire didn't list the radio's sound card"* ]]
|
||||
}
|
||||
|
||||
@test "configure adds a Graywolf channel on the radio's sound card when it has none" {
|
||||
configurable
|
||||
rm "$(GRAYWOLF_DB)"*
|
||||
graywolf_db
|
||||
run bash "$REPO/radio" configure
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Graywolf: a channel on the radio's sound card (plughw:CARD=CODEC,DEV=0), 1200 baud APRS, PTT through rigctld"* ]]
|
||||
[ "$(qlog_query "SELECT id, direction, source_type, source_path, sample_rate, channels FROM audio_devices ORDER BY id" "$(GRAYWOLF_DB)")" = "$(printf '1|input|soundcard|plughw:CARD=CODEC,DEV=0|48000|1\n2|output|soundcard|plughw:CARD=CODEC,DEV=0|48000|1')" ]
|
||||
[ "$(qlog_query "SELECT name, input_device_id, output_device_id, modem_type, bit_rate, mode FROM channels" "$(GRAYWOLF_DB)")" = "Icom IC-7300|1|2|afsk|1200|aprs" ]
|
||||
[ "$(qlog_query "SELECT channel_id, method, device FROM ptt_configs" "$(GRAYWOLF_DB)")" = "1|rigctld|127.0.0.1:4532" ]
|
||||
grep -qx "systemctl stop graywolf" "$STUB_LOG"
|
||||
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"Graywolf: already set up"* ]]
|
||||
[ "$(qlog_query "SELECT COUNT(*) FROM channels" "$(GRAYWOLF_DB)")" = 1 ]
|
||||
}
|
||||
|
||||
@test "configure doesn't add a Graywolf channel without a sound card, or beside channels you made" {
|
||||
configurable
|
||||
rm "$(GRAYWOLF_DB)"*
|
||||
graywolf_db 1:0
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"Graywolf: skipped: it has no channel that transmits yet"* ]]
|
||||
[ "$(qlog_query "SELECT COUNT(*) FROM channels" "$(GRAYWOLF_DB)")" = 1 ]
|
||||
|
||||
rm "$(GRAYWOLF_DB)"*
|
||||
graywolf_db
|
||||
rm -r "$RADIO_SYSFS/class/sound/card1"
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"Graywolf: skipped: it has no channel that transmits yet"* ]]
|
||||
[ "$(qlog_query "SELECT COUNT(*) FROM channels" "$(GRAYWOLF_DB)")" = 0 ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user