Move radio's detection into radio-detect.sh, for HamPackServer to share
check / lint-and-test (push) Failing after 4m21s
check / packages (push) Successful in 24s

Finding the radios, their ports, sound cards and CM108 pins, probing them
and looking them up in radios.conf move, unchanged, from radio into
radio-detect.sh, which radio sources. It needs nothing else of HamPack
(it has parse_conf itself where lib.sh isn't loaded), so HamPackServer's
configure can keep a copy. The messages that named radio's commands take
them from RADIO_PROGRAM, RADIO_CONFIGURE and RADIO_CM108_ACCESS, whose
defaults say what they said before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-29 14:13:18 -07:00
co-authored by Claude Opus 5.5
parent 7697a785d3
commit a88f09a1cd
4 changed files with 552 additions and 475 deletions
+24 -1
View File
@@ -143,6 +143,29 @@ answers() {
exec "$REAL_PYTHON3" "$@"'
}
@test "radio-detect.sh works on its own, without HamPack's lib.sh, as HamPackServer uses it" {
ic7300
run env -i PATH="$PATH" RADIO_SYSFS="$RADIO_SYSFS" RADIO_DEV="$RADIO_DEV" RADIO_PROGRAM=configure \
bash -c 'source "$1" || exit 9
declare -F conf_field > /dev/null || exit 8
find_radios || exit 7
identify "${RADIOS[0]}" never
echo "models=$ID_MODELS"
echo "port=$(port_path "${ID_PORTS[0]}")"
echo "card=$(card_name "${RADIOS[0]}")"
echo "hamlib=$(conf_field "Icom IC-7300" hamlib)"
echo "name=$(hamlib_name 3073)"
ANSWER_FIELD=civ ANSWER_VALUE=00 unknown_answer_text' _ "$REPO/radio-detect.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"models=Icom IC-7300|3073"* ]]
[[ "$output" == *"port=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001234-if00-port0"* ]]
[[ "$output" == *"card=hw:CARD=CODEC"* ]]
[[ "$output" == *"hamlib=3073"* ]]
[[ "$output" == *"name=Icom IC-7300"* ]]
# Messages name the program that sourced it
[[ "$output" == *"that configure doesn't know"* ]]
}
@test "recognises an Icom by its USB serial number, with its port and sound card" {
onboard_card
ic7300
@@ -1361,7 +1384,7 @@ FLRIG_AUTOSTART() { echo "$HOME/.config/autostart/hampack-flrig.desktop"; }
echo "$vid" > "$BATS_TEST_TMPDIR/d/$device/idVendor"
echo "$pid" > "$BATS_TEST_TMPDIR/d/$device/idProduct"
local in_radio=no in_rule=no pattern
bash -c 'source <(sed -n "/^attr() {/,/^}/p; /^cm108_compatible() {/,/^}/p" "$1"); cm108_compatible "$2"' _ "$REPO/radio" "$BATS_TEST_TMPDIR/d/$device" && in_radio=yes
bash -c 'source <(sed -n "/^attr() {/,/^}/p; /^cm108_compatible() {/,/^}/p" "$1"); cm108_compatible "$2"' _ "$REPO/radio-detect.sh" "$BATS_TEST_TMPDIR/d/$device" && in_radio=yes
for pattern in $(grep "idVendor}==\"$vid\"" <<< "$rule" | grep -oE 'idProduct}=="[^"]+"' | cut -d'"' -f2 | tr '|' ' '); do
# shellcheck disable=SC2053
[[ "$pid" == $pattern ]] && in_rule=yes