Add radio configure --flrig, which puts flrig in charge of the radio
check / lint-and-test (push) Successful in 3m23s
check / packages (push) Successful in 24s

flrig can't reach a radio through rigctld, and the two can't share its
port, so `radio configure` leaves flrig alone and says why. With --flrig,
flrig gets the radio, its by-id port, the baud rate it answered at and
PTT by CAT, and rigctld runs Hamlib's FLRig backend (model 4) against
flrig's XML-RPC port, so every other program still talks to rigctld.
Running it again without --flrig gives the port back to rigctld.

flrig's settings are FLTK preferences files: flrig.prefs names the
radio, and <radio>.prefs (which flrig reads only with a version in it)
has its port, baud rate (as its place in flrig's list) and PTT. Long
values carry on in lines starting with +, as FLTK writes them. A
different radio or port you set is left alone unless --force.

radios.conf gets flrig's names for the radios, from flrig 2.0.12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 13:39:00 -07:00
co-authored by Claude Opus 5.5
parent b2ffaf9592
commit 53e748ccb9
7 changed files with 265 additions and 20 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ EOF
}
check_radio() {
check_keys hamlib usb_serial cat_id civ
check_keys hamlib usb_serial cat_id civ flrig
check_required hamlib
[[ "${CONF[hamlib]}" =~ ^[0-9]+$ ]] || problem "hamlib= should be a Hamlib model number"
[ -n "${CONF[usb_serial]}${CONF[cat_id]}${CONF[civ]}" ] || problem "needs usb_serial=, cat_id= or civ="
+85
View File
@@ -377,6 +377,7 @@ configurable() {
JSON
chmod 600 "$HOME/.config/pat/config.json"
stub fldigi 'exit 0'
stub flrig 'exit 0'
mkdir -p "$HOME/.fldigi"
printf '<FLDIGI_DEFS>\n\n<!-- My call -->\n<MYCALL>N0CALL</MYCALL>\n\n<CHKUSEHAMLIBIS>0</CHKUSEHAMLIBIS>\n\n<CHKUSERIGCATIS>0</CHKUSERIGCATIS>\n\n<HAMRIGMODEL>0</HAMRIGMODEL>\n\n<HAMRIGDEVICE>/dev/rig</HAMRIGDEVICE>\n\n</FLDIGI_DEFS>\n' > "$HOME/.fldigi/fldigi_def.xml"
touch "$HOME/.local/bin/direwolf"
@@ -1071,3 +1072,87 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
run bash "$REPO/radio" configure --force
[ "$(jq -c '.rigs[1] | [.id, has("remoteAudioInput")]' "$(POTACAT_JSON)")" = '["rig_hampack",false]' ]
}
# --- flrig ---
FLRIG_PREFS() { echo "$HOME/.flrig/${1:-flrig}.prefs"; }
IC7300_PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001234-if00-port0
@test "configure leaves flrig alone, and says why, without --flrig" {
configurable
run bash "$REPO/radio" configure
[[ "$output" == *"flrig: not set up: it and rigctld can't both use the radio's port. \`radio configure --flrig\` puts flrig in charge of the radio"* ]]
[ ! -e "$HOME/.flrig" ]
}
@test "configure --flrig puts flrig in charge of the radio, with rigctld passing everything to it" {
configurable
run bash "$REPO/radio" configure --flrig
[ "$status" -eq 0 ]
[[ "${lines[0]}" == *"at 38400 baud, through flrig" ]]
[[ "$output" == *"rigctld: runs as the hampack-rigctld user service, on 127.0.0.1:4532, and passes everything to flrig"* ]]
[[ "$output" == *"flrig: controls the IC-7300 on $IC7300_PORT at 38400 baud, PTT by CAT. Start it before the other programs, and leave it running"* ]]
grep -qx "ExecStart=/usr/bin/rigctld -m 4 -r 127.0.0.1:12345 -T 127.0.0.1 -t 4532" "$HOME/.config/systemd/user/hampack-rigctld.service"
# As FLTK writes it
[ "$(head -5 "$(FLRIG_PREFS)")" = "$(printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: flrig\n\n[.]')" ]
grep -qx "xcvr_name:IC-7300" "$(FLRIG_PREFS)"
grep -qx "; application: IC-7300" "$(FLRIG_PREFS IC-7300)"
grep -qx "xcvr_serial_port:${IC7300_PORT:0:60}" "$(FLRIG_PREFS IC-7300)"
grep -qx "+${IC7300_PORT:60}" "$(FLRIG_PREFS IC-7300)"
grep -qx "serial_baudrate:7" "$(FLRIG_PREFS IC-7300)"
grep -qx "ptt_via_cat:1" "$(FLRIG_PREFS IC-7300)"
grep -q "^version:" "$(FLRIG_PREFS IC-7300)"
grep -qx "controller=flrig" "$HAMPACK_STATE/radio"
# The other programs still talk to rigctld
grep -qx "Rig=Hamlib NET rigctl" "$(WSJTX_INI)"
run bash "$REPO/radio" configure --flrig
[[ "$output" == *"flrig: already set up"* ]]
[ "$(grep -c '^xcvr_serial_port:' "$(FLRIG_PREFS IC-7300)")" -eq 1 ]
[ "$(grep -c '^+' "$(FLRIG_PREFS IC-7300)")" -eq 1 ]
# Back to rigctld on its own
run bash "$REPO/radio" configure
grep -q -- "-m 3073 -r $IC7300_PORT -s 38400" "$HOME/.config/systemd/user/hampack-rigctld.service"
grep -qx "controller=rigctld" "$HAMPACK_STATE/radio"
}
@test "configure --flrig keeps flrig's other settings, and uses its XML-RPC port" {
configurable
mkdir -p "$HOME/.flrig"
printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: IC-7300\n\n[.]\n\nversion:2.0.12\nmainx:100\nxcvr_serial_port:NONE\nxmlport:12346\nlong:%s\n+%s\n' "$(printf 'a%.0s' {1..60})" "bcd" > "$(FLRIG_PREFS IC-7300)"
run bash "$REPO/radio" configure --flrig
[ "$status" -eq 0 ]
grep -qx "ExecStart=/usr/bin/rigctld -m 4 -r 127.0.0.1:12346 -T 127.0.0.1 -t 4532" "$HOME/.config/systemd/user/hampack-rigctld.service"
grep -qx "version:2.0.12" "$(FLRIG_PREFS IC-7300)"
grep -qx "mainx:100" "$(FLRIG_PREFS IC-7300)"
grep -qx "+bcd" "$(FLRIG_PREFS IC-7300)"
! grep -qx "xcvr_serial_port:NONE" "$(FLRIG_PREFS IC-7300)"
}
@test "configure --flrig leaves flrig on another radio or port unless --force" {
configurable
mkdir -p "$HOME/.flrig"
printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: flrig\n\n[.]\n\nxcvr_name:FT-991A\n' > "$(FLRIG_PREFS)"
run bash "$REPO/radio" configure --flrig
[[ "$output" == *"flrig: Left its radio (FT-991A) alone: \`radio configure --force\` replaces it"* ]]
grep -qx "xcvr_name:FT-991A" "$(FLRIG_PREFS)"
run bash "$REPO/radio" configure --flrig --force
grep -qx "xcvr_name:IC-7300" "$(FLRIG_PREFS)"
ls "$(FLRIG_PREFS)".bak-* > /dev/null
}
@test "configure --flrig needs flrig quit, and knowing the radio" {
configurable
FAKE_RUNNING=flrig run bash "$REPO/radio" configure --flrig
[ "$status" -eq 1 ]
[[ "$output" == *"Quit flrig first"* ]]
[ ! -e "$HOME/.config/systemd/user/hampack-rigctld.service" ]
run bash "$REPO/radio" configure --flrig --model 2028
[ "$status" -eq 1 ]
[[ "$output" == *"radio doesn't know flrig's name for the Kenwood TS-480"* ]]
[ ! -e "$HOME/.config/systemd/user/hampack-rigctld.service" ]
}