Set up older Yaesus with radio configure --model, without asking them

The FT-817, FT-818, FT-857 and FT-897 have no ID command, and take every
five bytes they're sent as a command, so radio doesn't probe them: --model
sets one up on its only serial port, at the CAT rate it comes with
(baud= in radios.conf), or --baud's. Where nothing answered, radio says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-29 13:06:27 -07:00
co-authored by Claude Opus 5.5
parent 4794c186ee
commit d910982ea7
7 changed files with 149 additions and 14 deletions
+5 -3
View File
@@ -117,16 +117,18 @@ EOF
}
check_radio() {
check_keys hamlib usb_serial cat_id civ flrig elecraft
check_keys hamlib usb_serial cat_id civ flrig elecraft baud
[[ "${CONF[elecraft]:-K3}" =~ ^(K3|K3S|KX2|KX3|K4)$ ]] || problem "elecraft= should be K3, K3S, KX2, KX3 or K4"
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="
[ -n "${CONF[usb_serial]}${CONF[cat_id]}${CONF[civ]}${CONF[baud]}" ] || problem "needs usb_serial=, cat_id=, civ= or baud="
[ -z "${CONF[baud]}" ] || [ -z "${CONF[usb_serial]}${CONF[cat_id]}${CONF[civ]}" ] || problem "baud= is only for a radio radio can't recognise"
[[ "${CONF[baud]:-4800}" =~ ^(4800|9600|19200|38400|57600|115200)$ ]] || problem "baud= should be a serial rate"
[ -z "${CONF[cat_id]}" ] || [[ "${CONF[cat_id]}" =~ ^[0-9]{3,4}$ ]] || problem "cat_id= should be 3 or 4 digits"
[ -z "${CONF[civ]}" ] || [[ "${CONF[civ]}" =~ ^[0-9A-F]{2}$ ]] || problem "civ= should be two hex digits, in capitals"
}
@test "radios.conf: every radio has a Hamlib model and a way to recognise it" {
@test "radios.conf: every radio has a Hamlib model, and a way to recognise it or its CAT rate" {
parse_conf "$REPO/radios.conf" check_radio
check_unique_sections "$REPO/radios.conf"
no_problems
+60 -1
View File
@@ -397,7 +397,7 @@ teardown() {
fake_radio silent
run bash "$REPO/radio" probe "$PTY"
[ "$status" -eq 1 ]
[ "$output" = "Nothing answered on $PTY at 38400 115200 19200 9600 4800 baud" ]
[ "${lines[0]}" = "Nothing answered on $PTY at 38400 115200 19200 9600 4800 baud" ]
}
# --- radio configure ---
@@ -1711,3 +1711,62 @@ auto() {
run bash "$REPO/radio" unconfigure --force
[ "$status" -eq 2 ]
}
# --- radios that can't be asked ---
# An FT-817 on an FTDI CAT cable: one serial port, and no sound card
ft817() {
usb 1-4 0403:6001 FTDI "FT232R USB UART" A12345
port 1-4 ttyUSB0 usb-FTDI_FT232R_USB_UART_A12345-if00-port0
stub pgrep 'exit 1'
stub systemctl '[ "$*" != "--user is-active --quiet hampack-rigctld" ]'
answers ttyUSB0 ""
}
@test "configure --model sets up a radio that can't be asked, without asking it" {
ft817
: > "$STUB_LOG"
run bash "$REPO/radio" configure --model 1020
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Setting up the Yaesu FT-817 (Hamlib model 1020), on /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A12345-if00-port0 at 4800 baud" ]
[ "${lines[1]}" = "It can't be asked what it is, so check it's a Yaesu FT-817, and that its CAT RATE menu says 4800 (or give --baud)." ]
! grep -q "TIOCMBIC" "$STUB_LOG"
grep -qx "ExecStart=/usr/bin/rigctld -m 1020 -r /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A12345-if00-port0 -s 4800 -T 127.0.0.1 -t 4532" "$HOME/.config/systemd/user/hampack-rigctld.service"
grep -qx "name=Yaesu FT-817" "$HAMPACK_STATE/radio"
run bash "$REPO/radio" configure --model 1022 --baud 38400
[ "$status" -eq 0 ]
grep -q "^ExecStart=/usr/bin/rigctld -m 1022 .* -s 38400 " "$HOME/.config/systemd/user/hampack-rigctld.service"
}
@test "configure --model --flrig gives flrig a radio that can't be asked" {
ft817
stub flrig 'exit 0'
run bash "$REPO/radio" configure --model 1041 --flrig
[ "$status" -eq 0 ]
[[ "$output" == *"flrig: controls the FT-818ND on /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A12345-if00-port0 at 4800 baud"* ]]
grep -qx "xcvr_name:FT-818ND" "$(FLRIG_PREFS)"
}
@test "configure only takes --baud for a radio that can't be asked, and won't guess its port" {
ft817
run bash "$REPO/radio" configure --baud 9600
[ "$status" -eq 2 ]
[[ "$output" == "--baud is for a radio radio can't ask"* ]]
run bash "$REPO/radio" configure --model 3073 --baud 9600
[ "$status" -eq 2 ]
port 1-4 ttyUSB1 "" 1
run bash "$REPO/radio" configure --model 1020
[ "$status" -eq 2 ]
[[ "$output" == "The Yaesu FT-817 can't be asked which of ttyUSB0 ttyUSB1 it's on"* ]]
}
@test "says how to set up a radio that can't be asked, when nothing answers" {
ft817
run bash "$REPO/radio" --probe
[[ "$output" == *"An FT-817, FT-818, FT-857 or FT-897 can't be asked what it is: give its Hamlib model, as in \`radio configure --model 1020\`"* ]]
run bash "$REPO/radio" probe "$RADIO_DEV/ttyUSB0"
[ "$status" -eq 1 ]
[[ "$output" == *"radio configure --model 1020"* ]]
}