Add radio configure --flrig, which puts flrig in charge of the radio
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:
co-authored by
Claude Opus 5.5
parent
b2ffaf9592
commit
53e748ccb9
@@ -17,9 +17,11 @@ control a radio.
|
|||||||
the model
|
the model
|
||||||
- [ ] `radio configure`, the rest. It writes the rigctld user service and
|
- [ ] `radio configure`, the rest. It writes the rigctld user service and
|
||||||
points WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm, QLog, POTACAT
|
points WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm, QLog, POTACAT
|
||||||
and Graywolf at it. Still to do:
|
and Graywolf at it, or with --flrig, puts flrig in charge of the radio
|
||||||
- [ ] flrig can't use rigctld, so it can't run alongside it. Say so, or
|
behind rigctld. Still to do:
|
||||||
offer flrig as the controller instead
|
- [ ] With --flrig, nothing starts flrig: rigctld retries until it's
|
||||||
|
running. An autostart entry for flrig, or a user service, would save
|
||||||
|
starting it by hand
|
||||||
- [ ] More than one radio at once: a rigctld for each, on its own port
|
- [ ] More than one radio at once: a rigctld for each, on its own port
|
||||||
- [ ] rigctld retries every 5 seconds while the radio is off or unplugged.
|
- [ ] rigctld retries every 5 seconds while the radio is off or unplugged.
|
||||||
Start it when the radio is plugged in instead (see hotplug below)
|
Start it when the radio is plugged in instead (see hotplug below)
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ Probing opens the port, which raises its DTR and RTS lines for a moment before `
|
|||||||
|
|
||||||
It also gives WSJT-X, JS8Call, fldigi, Dire Wolf, not1mm's voice keyer and POTACAT the radio's sound card. POTACAT finds it by name the next time it starts. WSJT-X and JS8Call get it as PipeWire names it, so PipeWire must be running. fldigi and not1mm get PipeWire's name for it too where PortAudio lists it (through PipeWire's JACK support), since ALSA's name for it has a card number that can change between boots; if it does, run `radio configure` again. If Graywolf has no channels yet, it gets one on the radio's sound card, for 1200 baud APRS.
|
It also gives WSJT-X, JS8Call, fldigi, Dire Wolf, not1mm's voice keyer and POTACAT the radio's sound card. POTACAT finds it by name the next time it starts. WSJT-X and JS8Call get it as PipeWire names it, so PipeWire must be running. fldigi and not1mm get PipeWire's name for it too where PortAudio lists it (through PipeWire's JACK support), since ALSA's name for it has a card number that can change between boots; if it does, run `radio configure` again. If Graywolf has no channels yet, it gets one on the radio's sound card, for 1200 baud APRS.
|
||||||
|
|
||||||
`radio configure` only fills in rig and sound settings you haven't set (a sound device of "default" or "pipewire" counts as not set). `radio configure --force` replaces them, and every file it changes is backed up first. With more than one radio plugged in, give the number `radio` lists for it: `radio configure 2`. For a radio it can't tell apart from others, give its Hamlib model number: `radio configure --model 2045`. `radio configure` also says which sound card is the radio's.
|
`radio configure` only fills in rig and sound settings you haven't set (a sound device of "default" or "pipewire" counts as not set). `radio configure --force` replaces them, and every file it changes is backed up first. With more than one radio plugged in, give the number `radio` lists for it: `radio configure 2`. For a radio it can't tell apart from others, give its Hamlib model number: `radio configure --model 2045`.
|
||||||
|
|
||||||
|
flrig can't reach a radio through rigctld, and the two can't share its port, so `radio configure` leaves flrig alone. If you'd rather flrig controlled the radio, run `radio configure --flrig`: flrig gets the radio, and rigctld passes the other programs through it, using Hamlib's FLRig support. Then start flrig before the other programs, and leave it running. `radio configure` also says which sound card is the radio's.
|
||||||
|
|
||||||
The radios it knows are in `radios.conf`. If your radio isn't recognised, or answers with something `radio` doesn't know, please open an issue with what `radio detect --probe` printed.
|
The radios it knows are in `radios.conf`. If your radio isn't recognised, or answers with something `radio` doesn't know, please open an issue with what `radio detect --probe` printed.
|
||||||
|
|
||||||
|
|||||||
@@ -106,14 +106,23 @@ Dire Wolf, not1mm, QLog and POTACAT quit:
|
|||||||
cheap USB chips where only hw: works; note if this is one.
|
cheap USB chips where only hw: works; note if this is one.
|
||||||
12. Run `radio configure` again: each program is "already set up", and
|
12. Run `radio configure` again: each program is "already set up", and
|
||||||
rigctld restarts.
|
rigctld restarts.
|
||||||
13. With a rig set by hand in WSJT-X, `radio configure` leaves it alone, and
|
13. Quit everything, run `radio configure --flrig`, and start flrig. It opens
|
||||||
|
on the radio, on its by-id port at the baud rate `radio` found, with PTT
|
||||||
|
by CAT, and shows the radio's frequency. `rigctl -m 2 -r 127.0.0.1:4532 f`
|
||||||
|
shows the same frequency, through rigctld and flrig. WSJT-X's "Test CAT"
|
||||||
|
and "Test PTT" still work. Quit flrig: rigctld loses the radio, and gets
|
||||||
|
it back within a few seconds of starting flrig again. Then run
|
||||||
|
`radio configure` without --flrig, and check rigctld has the radio's port
|
||||||
|
again. The settings were checked against flrig 2.0.12's source and FLTK
|
||||||
|
1.4.5's preferences format.
|
||||||
|
14. With a rig set by hand in WSJT-X, `radio configure` leaves it alone, and
|
||||||
`--force` replaces it. The `.bak-` copy has the old settings.
|
`--force` replaces it. The `.bak-` copy has the old settings.
|
||||||
14. Unplug the radio, plug it in again, and check rigctld reconnects within
|
15. Unplug the radio, plug it in again, and check rigctld reconnects within
|
||||||
a few seconds. Reboot and check it starts at login.
|
a few seconds. Reboot and check it starts at login.
|
||||||
|
|
||||||
| Date | Commit | Radio | rigctld | WSJT-X | JS8Call | Pat | fldigi | Dire Wolf | not1mm | QLog | POTACAT | Graywolf | Notes |
|
| Date | Commit | Radio | rigctld | WSJT-X | JS8Call | Pat | fldigi | Dire Wolf | not1mm | QLog | POTACAT | Graywolf | flrig | Notes |
|
||||||
|------|--------|-------|---------|--------|---------|-----|--------|-----------|--------|------|---------|----------|-------|
|
|------|--------|-------|---------|--------|---------|-----|--------|-----------|--------|------|---------|----------|-------|-------|
|
||||||
| | | | | | | | | | | | | | |
|
| | | | | | | | | | | | | | | |
|
||||||
|
|
||||||
## Pairing radios with sound cards
|
## Pairing radios with sound cards
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# Usage : radio [detect] [--probe]
|
# Usage : radio [detect] [--probe]
|
||||||
# radio probe PORT
|
# radio probe PORT
|
||||||
# radio configure [--force] [--model N] [NUMBER]
|
# radio configure [--force] [--model N] [--flrig] [NUMBER]
|
||||||
# radio help
|
# radio help
|
||||||
|
|
||||||
SELF="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
SELF="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||||||
@@ -35,6 +35,9 @@ QLOG_FLATPAK=io.github.foldynl.QLog
|
|||||||
QLOG_DB="$HOME/.var/app/$QLOG_FLATPAK/data/hamradio/QLog/qlog.db"
|
QLOG_DB="$HOME/.var/app/$QLOG_FLATPAK/data/hamradio/QLog/qlog.db"
|
||||||
POTACAT_DIR="$CONFIG_HOME/potacat"
|
POTACAT_DIR="$CONFIG_HOME/potacat"
|
||||||
GRAYWOLF_DB="$HOME/.local/share/graywolf/graywolf.db"
|
GRAYWOLF_DB="$HOME/.local/share/graywolf/graywolf.db"
|
||||||
|
FLRIG_DIR="$HOME/.flrig"
|
||||||
|
# flrig's baud rates; it saves the rate as its place in this list
|
||||||
|
FLRIG_BAUDS=(300 600 1200 2400 4800 9600 19200 38400 57600 115200 230400 460800)
|
||||||
DIREWOLF_CONF="$HAMPACK_STATE/conf.d/direwolf.conf"
|
DIREWOLF_CONF="$HAMPACK_STATE/conf.d/direwolf.conf"
|
||||||
# What HamPack's conf.d/direwolf.conf ships with, which configure replaces
|
# What HamPack's conf.d/direwolf.conf ships with, which configure replaces
|
||||||
DIREWOLF_DEFAULT_ADEVICE="plughw:0,0"
|
DIREWOLF_DEFAULT_ADEVICE="plughw:0,0"
|
||||||
@@ -63,6 +66,9 @@ Usage: radio [detect] [--probe]
|
|||||||
--force Replace rig settings you've set yourself
|
--force Replace rig settings you've set yourself
|
||||||
--model N Use Hamlib model N (\`rigctl -l\`), for a radio that radio
|
--model N Use Hamlib model N (\`rigctl -l\`), for a radio that radio
|
||||||
can't tell apart from others, or doesn't know
|
can't tell apart from others, or doesn't know
|
||||||
|
--flrig Put flrig in charge of the radio, with rigctld passing the
|
||||||
|
other programs through it. flrig then has to be running
|
||||||
|
for them to reach the radio
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,6 +597,86 @@ configure_qt_app() {
|
|||||||
say_changes "$name"
|
say_changes "$name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a value from an FLTK preferences file, as flrig keeps its settings:
|
||||||
|
# fltk_get FILE KEY. A long value carries on in lines that start with +
|
||||||
|
fltk_get() {
|
||||||
|
[ -f "$1" ] || return 0
|
||||||
|
K="$2" awk '
|
||||||
|
found && /^\+/ { value = value substr($0, 2); next }
|
||||||
|
found { exit }
|
||||||
|
index($0, ENVIRON["K"] ":") == 1 { value = substr($0, length(ENVIRON["K"]) + 2); found = 1 }
|
||||||
|
END { if (found) print value }
|
||||||
|
' "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set a value in an FLTK preferences file, making the file if need be:
|
||||||
|
# fltk_set FILE APPLICATION KEY VALUE. Values are written as FLTK writes them:
|
||||||
|
# 60 characters on the key's line, then 80 a line on lines starting with +
|
||||||
|
fltk_set() {
|
||||||
|
local tmp
|
||||||
|
mkdir -p "$(dirname "$1")" || return 1
|
||||||
|
[ -f "$1" ] || printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: %s\n\n[.]\n\n' "$2" > "$1" || return 1
|
||||||
|
tmp="$(mktemp "$1.XXXXXX")" || return 1
|
||||||
|
K="$3" V="$4" awk '
|
||||||
|
function put( v) {
|
||||||
|
v = ENVIRON["V"]
|
||||||
|
print ENVIRON["K"] ":" substr(v, 1, 60)
|
||||||
|
for (v = substr(v, 61); v != ""; v = substr(v, 81)) print "+" substr(v, 1, 80)
|
||||||
|
done = 1
|
||||||
|
}
|
||||||
|
skipping && /^\+/ { next }
|
||||||
|
{ skipping = 0 }
|
||||||
|
index($0, ENVIRON["K"] ":") == 1 { skipping = 1; next }
|
||||||
|
{ print }
|
||||||
|
$0 == "[.]" && !done { put() }
|
||||||
|
END { if (!done) put() }
|
||||||
|
' "$1" > "$tmp" && chmod --reference="$1" "$tmp" && mv -f "$tmp" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# flrig can't reach a radio through rigctld, and the two can't both have its
|
||||||
|
# port open. With --flrig, flrig gets the radio, its port, baud rate and PTT
|
||||||
|
# by CAT, and rigctld (Hamlib's FLRig backend) passes everything to it;
|
||||||
|
# otherwise flrig is left alone. configure_flrig FLRIG_NAME PORT BAUD
|
||||||
|
configure_flrig() {
|
||||||
|
local main="$FLRIG_DIR/flrig.prefs" rig="$FLRIG_DIR/$1.prefs" current_name current_port index i version
|
||||||
|
if ! command -v flrig > /dev/null; then
|
||||||
|
report flrig "not installed"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if (( ! USE_FLRIG )); then
|
||||||
|
report 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, with rigctld passing the other programs through it"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
for i in "${!FLRIG_BAUDS[@]}"; do
|
||||||
|
[ "${FLRIG_BAUDS[i]}" = "$3" ] && index="$i"
|
||||||
|
done
|
||||||
|
current_name="$(fltk_get "$main" xcvr_name)"
|
||||||
|
current_port="$(fltk_get "$rig" xcvr_serial_port)"
|
||||||
|
SAID=() LEFT=()
|
||||||
|
if [ "$current_name" = "$1" ] && [ "$current_port" = "$2" ] && [ "$(fltk_get "$rig" serial_baudrate)" = "$index" ] &&
|
||||||
|
[ "$(fltk_get "$rig" ptt_via_cat)" = 1 ]; then
|
||||||
|
report flrig "already set up. Start it before the other programs, and leave it running"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if (( ! FORCE )) && { [[ ! "$current_name" =~ ^(|NONE|$1)$ ]] || [[ ! "$current_port" =~ ^(|NONE)$ && "$current_port" != "$2" ]]; }; then
|
||||||
|
[[ "$current_name" =~ ^(|NONE|$1)$ ]] && LEFT+=("its port ($current_port)") || LEFT+=("its radio ($current_name)")
|
||||||
|
say_changes flrig
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
back_up "$main"
|
||||||
|
back_up "$rig"
|
||||||
|
# flrig only reads a radio's settings file that has a version in it
|
||||||
|
version="$(fltk_get "$rig" version)"
|
||||||
|
[ -n "$version" ] || version="$(pacman -Q flrig 2> /dev/null | awk '{ sub(/-[^-]*$/, "", $2); print $2 }')"
|
||||||
|
if ! { fltk_set "$main" flrig xcvr_name "$1" && fltk_set "$rig" "$1" version "${version:-2.0}" &&
|
||||||
|
fltk_set "$rig" "$1" xcvr_serial_port "$2" && fltk_set "$rig" "$1" serial_baudrate "$index" &&
|
||||||
|
fltk_set "$rig" "$1" ptt_via_cat 1; }; then
|
||||||
|
report flrig "couldn't change its settings in $FLRIG_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
report flrig "controls the $1 on $2 at $3 baud, PTT by CAT. Start it before the other programs, and leave it running"
|
||||||
|
}
|
||||||
|
|
||||||
# Pat: add rigctld to its rigs as "hampack", and use it for ARDOP and VARA
|
# Pat: add rigctld to its rigs as "hampack", and use it for ARDOP and VARA
|
||||||
# where no rig is set
|
# where no rig is set
|
||||||
configure_pat() {
|
configure_pat() {
|
||||||
@@ -1236,14 +1322,16 @@ configure_graywolf() {
|
|||||||
say_changes Graywolf
|
say_changes Graywolf
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write and (re)start rigctld's user service: write_rigctld NAME HAMLIB PORT BAUD
|
# Write and (re)start rigctld's user service: write_rigctld DESCRIPTION
|
||||||
|
# RIGCTLD_ARGS..., the arguments that say which radio and how to reach it
|
||||||
write_rigctld() {
|
write_rigctld() {
|
||||||
local unit
|
local unit description="$1"
|
||||||
|
shift
|
||||||
unit="[Unit]
|
unit="[Unit]
|
||||||
Description=Hamlib rigctld for the $1 (written by HamPack's radio configure)
|
Description=Hamlib rigctld for $description (written by HamPack's radio configure)
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/rigctld -m $2 -r $3 -s $4 -T ${RIGCTLD_ADDR%:*} -t ${RIGCTLD_ADDR#*:}
|
ExecStart=/usr/bin/rigctld $* -T ${RIGCTLD_ADDR%:*} -t ${RIGCTLD_ADDR#*:}
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|
||||||
@@ -1256,6 +1344,14 @@ WantedBy=default.target"
|
|||||||
systemctl --user restart hampack-rigctld
|
systemctl --user restart hampack-rigctld
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a field of a radio in radios.conf: conf_field NAME FIELD
|
||||||
|
conf_field() {
|
||||||
|
awk -v name="$1" -v field="$2" '
|
||||||
|
/^\[/ { in_radio = ($0 == "[" name "]"); next }
|
||||||
|
in_radio && index($0, field "=") == 1 { print substr($0, length(field) + 2); exit }
|
||||||
|
' "$RADIOS_CONF"
|
||||||
|
}
|
||||||
|
|
||||||
# Print the name radios.conf gives a Hamlib model, or nothing
|
# Print the name radios.conf gives a Hamlib model, or nothing
|
||||||
hamlib_name() {
|
hamlib_name() {
|
||||||
awk -F= -v m="$1" '/^\[/ { name = substr($0, 2, length($0) - 2) } $1 == "hamlib" && $2 == m { print name; exit }' "$RADIOS_CONF"
|
awk -F= -v m="$1" '/^\[/ { name = substr($0, 2, length($0) - 2) } $1 == "hamlib" && $2 == m { print name; exit }' "$RADIOS_CONF"
|
||||||
@@ -1263,11 +1359,12 @@ hamlib_name() {
|
|||||||
|
|
||||||
# radio configure: set up rigctld for a radio and point the programs at it
|
# radio configure: set up rigctld for a radio and point the programs at it
|
||||||
configure() {
|
configure() {
|
||||||
local number="" model="" radio was_running=0 name port baud card
|
local number="" model="" radio was_running=0 name port baud card flrig_name="" flrig_port=12345
|
||||||
FORCE=0 BACKUPS=()
|
FORCE=0 BACKUPS=() USE_FLRIG=0
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--force) FORCE=1 ;;
|
--force) FORCE=1 ;;
|
||||||
|
--flrig) USE_FLRIG=1 ;;
|
||||||
--model)
|
--model)
|
||||||
[[ "${2:-}" =~ ^[0-9]+$ ]] || { usage >&2; return 2; }
|
[[ "${2:-}" =~ ^[0-9]+$ ]] || { usage >&2; return 2; }
|
||||||
model="$2"
|
model="$2"
|
||||||
@@ -1296,6 +1393,16 @@ configure() {
|
|||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
radio="${RADIOS[number - 1]}"
|
radio="${RADIOS[number - 1]}"
|
||||||
|
if (( USE_FLRIG )); then
|
||||||
|
if ! command -v flrig > /dev/null; then
|
||||||
|
echo "flrig isn't installed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if running flrig; then
|
||||||
|
echo "Quit flrig first: it has the radio's port open, and saves its settings when it quits."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# rigctld has the port open, if radio configure has run before
|
# rigctld has the port open, if radio configure has run before
|
||||||
if systemctl --user is-active --quiet hampack-rigctld 2> /dev/null; then
|
if systemctl --user is-active --quiet hampack-rigctld 2> /dev/null; then
|
||||||
@@ -1327,6 +1434,16 @@ configure() {
|
|||||||
(( ! was_running )) || systemctl --user start hampack-rigctld
|
(( ! was_running )) || systemctl --user start hampack-rigctld
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
if (( USE_FLRIG )); then
|
||||||
|
flrig_name="$(conf_field "$name" flrig)"
|
||||||
|
if [ -z "$flrig_name" ]; then
|
||||||
|
echo "radio doesn't know flrig's name for the $name, if flrig has a driver for it. Choose the radio in flrig yourself, or run \`radio configure\` without --flrig."
|
||||||
|
(( ! was_running )) || systemctl --user start hampack-rigctld
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
flrig_port="$(fltk_get "$FLRIG_DIR/$flrig_name.prefs" xmlport)"
|
||||||
|
flrig_port="${flrig_port:-12345}"
|
||||||
|
fi
|
||||||
port="$(port_path "$ID_CAT_PORT")"
|
port="$(port_path "$ID_CAT_PORT")"
|
||||||
baud="$ID_BAUD"
|
baud="$ID_BAUD"
|
||||||
card="$(card_name "$radio")"
|
card="$(card_name "$radio")"
|
||||||
@@ -1336,9 +1453,11 @@ configure() {
|
|||||||
find_pipewire_nodes "$card_number" && pipewire=1
|
find_pipewire_nodes "$card_number" && pipewire=1
|
||||||
PORTAUDIO_DEVICES="$(portaudio_devices)" || PORTAUDIO_DEVICES=""
|
PORTAUDIO_DEVICES="$(portaudio_devices)" || PORTAUDIO_DEVICES=""
|
||||||
|
|
||||||
echo "Setting up the $name (Hamlib model $model), on $port at $baud baud"
|
echo "Setting up the $name (Hamlib model $model), on $port at $baud baud$( (( USE_FLRIG )) && echo ", through flrig")"
|
||||||
echo
|
echo
|
||||||
if write_rigctld "$name" "$model" "$port" "$baud"; then
|
if (( USE_FLRIG )) && write_rigctld "flrig, which controls the $name" -m 4 -r "127.0.0.1:$flrig_port"; then
|
||||||
|
report rigctld "runs as the hampack-rigctld user service, on $RIGCTLD_ADDR, and passes everything to flrig"
|
||||||
|
elif (( ! USE_FLRIG )) && write_rigctld "the $name" -m "$model" -r "$port" -s "$baud"; then
|
||||||
report rigctld "runs as the hampack-rigctld user service, on $RIGCTLD_ADDR"
|
report rigctld "runs as the hampack-rigctld user service, on $RIGCTLD_ADDR"
|
||||||
else
|
else
|
||||||
report rigctld "couldn't start: see \`systemctl --user status hampack-rigctld\`"
|
report rigctld "couldn't start: see \`systemctl --user status hampack-rigctld\`"
|
||||||
@@ -1356,6 +1475,7 @@ configure() {
|
|||||||
else
|
else
|
||||||
report JS8Call "not installed"
|
report JS8Call "not installed"
|
||||||
fi
|
fi
|
||||||
|
configure_flrig "$flrig_name" "$port" "$baud"
|
||||||
configure_pat
|
configure_pat
|
||||||
configure_fldigi "$card_number"
|
configure_fldigi "$card_number"
|
||||||
configure_direwolf "$card"
|
configure_direwolf "$card"
|
||||||
@@ -1365,7 +1485,8 @@ configure() {
|
|||||||
configure_graywolf "$card" "$name"
|
configure_graywolf "$card" "$name"
|
||||||
|
|
||||||
mkdir -p "$HAMPACK_STATE" &&
|
mkdir -p "$HAMPACK_STATE" &&
|
||||||
printf 'name=%s\nhamlib=%s\nport=%s\nbaud=%s\ncard=%s\n' "$name" "$model" "$port" "$baud" "$card" > "$HAMPACK_STATE/radio"
|
printf 'name=%s\nhamlib=%s\nport=%s\nbaud=%s\ncard=%s\ncontroller=%s\n' "$name" "$model" "$port" "$baud" "$card" \
|
||||||
|
"$( (( USE_FLRIG )) && echo flrig || echo rigctld)" > "$HAMPACK_STATE/radio"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ -z "$card" ]; then
|
if [ -z "$card" ]; then
|
||||||
|
|||||||
+26
@@ -10,6 +10,9 @@
|
|||||||
# may give the same reply
|
# may give the same reply
|
||||||
# civ= - the radio's default CI-V address in hex (Icom). The radio
|
# civ= - the radio's default CI-V address in hex (Icom). The radio
|
||||||
# gives it in its reply to "read transceiver ID"
|
# gives it in its reply to "read transceiver ID"
|
||||||
|
# flrig= - flrig's name for the radio, for `radio configure --flrig`
|
||||||
|
# (flrig 2.0.12's rigs/ sources). Left out where flrig has
|
||||||
|
# no driver for it, or several (the TS-480's HX and SAT)
|
||||||
#
|
#
|
||||||
# A radio needs usb_serial=, cat_id= or civ=, or `radio` can't recognise it.
|
# A radio needs usb_serial=, cat_id= or civ=, or `radio` can't recognise it.
|
||||||
# The Hamlib model numbers were checked against Hamlib 4.6. The other values
|
# The Hamlib model numbers were checked against Hamlib 4.6. The other values
|
||||||
@@ -20,26 +23,31 @@
|
|||||||
|
|
||||||
[Icom IC-7300]
|
[Icom IC-7300]
|
||||||
hamlib=3073
|
hamlib=3073
|
||||||
|
flrig=IC-7300
|
||||||
usb_serial=IC-7300 *
|
usb_serial=IC-7300 *
|
||||||
civ=94
|
civ=94
|
||||||
|
|
||||||
[Icom IC-705]
|
[Icom IC-705]
|
||||||
hamlib=3085
|
hamlib=3085
|
||||||
|
flrig=IC-705
|
||||||
usb_serial=IC-705 *
|
usb_serial=IC-705 *
|
||||||
civ=A4
|
civ=A4
|
||||||
|
|
||||||
[Icom IC-7610]
|
[Icom IC-7610]
|
||||||
hamlib=3078
|
hamlib=3078
|
||||||
|
flrig=IC-7610
|
||||||
usb_serial=IC-7610 *
|
usb_serial=IC-7610 *
|
||||||
civ=98
|
civ=98
|
||||||
|
|
||||||
[Icom IC-9700]
|
[Icom IC-9700]
|
||||||
hamlib=3081
|
hamlib=3081
|
||||||
|
flrig=IC-9700
|
||||||
usb_serial=IC-9700 *
|
usb_serial=IC-9700 *
|
||||||
civ=A2
|
civ=A2
|
||||||
|
|
||||||
[Icom IC-7100]
|
[Icom IC-7100]
|
||||||
hamlib=3070
|
hamlib=3070
|
||||||
|
flrig=IC-7100
|
||||||
usb_serial=IC-7100 *
|
usb_serial=IC-7100 *
|
||||||
civ=88
|
civ=88
|
||||||
|
|
||||||
@@ -53,22 +61,27 @@ civ=AC
|
|||||||
|
|
||||||
[Yaesu FT-991A]
|
[Yaesu FT-991A]
|
||||||
hamlib=1035
|
hamlib=1035
|
||||||
|
flrig=FT-991A
|
||||||
cat_id=0670
|
cat_id=0670
|
||||||
|
|
||||||
[Yaesu FT-991]
|
[Yaesu FT-991]
|
||||||
hamlib=1035
|
hamlib=1035
|
||||||
|
flrig=FT-991
|
||||||
cat_id=0570
|
cat_id=0570
|
||||||
|
|
||||||
[Yaesu FT-891]
|
[Yaesu FT-891]
|
||||||
hamlib=1036
|
hamlib=1036
|
||||||
|
flrig=FT-891
|
||||||
cat_id=0650
|
cat_id=0650
|
||||||
|
|
||||||
[Yaesu FTDX10]
|
[Yaesu FTDX10]
|
||||||
hamlib=1042
|
hamlib=1042
|
||||||
|
flrig=FTDX10
|
||||||
cat_id=0761
|
cat_id=0761
|
||||||
|
|
||||||
[Yaesu FTDX101D]
|
[Yaesu FTDX101D]
|
||||||
hamlib=1040
|
hamlib=1040
|
||||||
|
flrig=FTDX101D
|
||||||
cat_id=0681
|
cat_id=0681
|
||||||
|
|
||||||
[Yaesu FTDX101MP]
|
[Yaesu FTDX101MP]
|
||||||
@@ -77,24 +90,29 @@ cat_id=0682
|
|||||||
|
|
||||||
[Yaesu FT-710]
|
[Yaesu FT-710]
|
||||||
hamlib=1049
|
hamlib=1049
|
||||||
|
flrig=FT-710
|
||||||
cat_id=0800
|
cat_id=0800
|
||||||
|
|
||||||
[Yaesu FTDX3000]
|
[Yaesu FTDX3000]
|
||||||
hamlib=1037
|
hamlib=1037
|
||||||
|
flrig=FTDX3000
|
||||||
cat_id=0460
|
cat_id=0460
|
||||||
|
|
||||||
[Yaesu FT-950]
|
[Yaesu FT-950]
|
||||||
hamlib=1028
|
hamlib=1028
|
||||||
|
flrig=FT-950
|
||||||
cat_id=0310
|
cat_id=0310
|
||||||
|
|
||||||
[Yaesu FT-450D]
|
[Yaesu FT-450D]
|
||||||
hamlib=1046
|
hamlib=1046
|
||||||
|
flrig=FT-450D
|
||||||
cat_id=0241
|
cat_id=0241
|
||||||
|
|
||||||
# Kenwood
|
# Kenwood
|
||||||
|
|
||||||
[Kenwood TS-2000]
|
[Kenwood TS-2000]
|
||||||
hamlib=2014
|
hamlib=2014
|
||||||
|
flrig=TS-2000
|
||||||
cat_id=019
|
cat_id=019
|
||||||
|
|
||||||
[Kenwood TS-480]
|
[Kenwood TS-480]
|
||||||
@@ -103,34 +121,42 @@ cat_id=020
|
|||||||
|
|
||||||
[Kenwood TS-590S]
|
[Kenwood TS-590S]
|
||||||
hamlib=2031
|
hamlib=2031
|
||||||
|
flrig=TS-590S
|
||||||
cat_id=021
|
cat_id=021
|
||||||
|
|
||||||
[Kenwood TS-990S]
|
[Kenwood TS-990S]
|
||||||
hamlib=2039
|
hamlib=2039
|
||||||
|
flrig=TS-990
|
||||||
cat_id=022
|
cat_id=022
|
||||||
|
|
||||||
[Kenwood TS-590SG]
|
[Kenwood TS-590SG]
|
||||||
hamlib=2037
|
hamlib=2037
|
||||||
|
flrig=TS-590SG
|
||||||
cat_id=023
|
cat_id=023
|
||||||
|
|
||||||
[Kenwood TS-890S]
|
[Kenwood TS-890S]
|
||||||
hamlib=2041
|
hamlib=2041
|
||||||
|
flrig=TS-890S
|
||||||
cat_id=024
|
cat_id=024
|
||||||
|
|
||||||
# Elecraft. They all answer ID; as a Kenwood TS-570 would
|
# Elecraft. They all answer ID; as a Kenwood TS-570 would
|
||||||
|
|
||||||
[Elecraft K3]
|
[Elecraft K3]
|
||||||
hamlib=2029
|
hamlib=2029
|
||||||
|
flrig=K3
|
||||||
cat_id=017
|
cat_id=017
|
||||||
|
|
||||||
[Elecraft KX3]
|
[Elecraft KX3]
|
||||||
hamlib=2045
|
hamlib=2045
|
||||||
|
flrig=KX3
|
||||||
cat_id=017
|
cat_id=017
|
||||||
|
|
||||||
[Elecraft KX2]
|
[Elecraft KX2]
|
||||||
hamlib=2044
|
hamlib=2044
|
||||||
|
flrig=KX2
|
||||||
cat_id=017
|
cat_id=017
|
||||||
|
|
||||||
[Elecraft K4]
|
[Elecraft K4]
|
||||||
hamlib=2047
|
hamlib=2047
|
||||||
|
flrig=K4
|
||||||
cat_id=017
|
cat_id=017
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_radio() {
|
check_radio() {
|
||||||
check_keys hamlib usb_serial cat_id civ
|
check_keys hamlib usb_serial cat_id civ flrig
|
||||||
check_required hamlib
|
check_required hamlib
|
||||||
[[ "${CONF[hamlib]}" =~ ^[0-9]+$ ]] || problem "hamlib= should be a Hamlib model number"
|
[[ "${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]}" ] || problem "needs usb_serial=, cat_id= or civ="
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ configurable() {
|
|||||||
JSON
|
JSON
|
||||||
chmod 600 "$HOME/.config/pat/config.json"
|
chmod 600 "$HOME/.config/pat/config.json"
|
||||||
stub fldigi 'exit 0'
|
stub fldigi 'exit 0'
|
||||||
|
stub flrig 'exit 0'
|
||||||
mkdir -p "$HOME/.fldigi"
|
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"
|
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"
|
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
|
run bash "$REPO/radio" configure --force
|
||||||
[ "$(jq -c '.rigs[1] | [.id, has("remoteAudioInput")]' "$(POTACAT_JSON)")" = '["rig_hampack",false]' ]
|
[ "$(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" ]
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user