Point not1mm and QLog at rigctld in radio configure
not1mm gets rigctld at 127.0.0.1:4532, with flrig and TCI off, unless it has rig control set up already. QLog keeps rig profiles in its log database, so it gets a "HamPack" profile there (Hamlib NET rigctl, 127.0.0.1:4532), selected, with the values QLog 0.54.2's own form gives a new profile. It's added only if there are no profiles yet, or with --force, and only when QLog isn't running and its log has the columns it needs. The log is backed up first through SQLite, so the backup includes what's still in qlog.db-wal. The probe tests' python3 stub now fakes only the probe, so QLog's step runs against a real SQLite log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a02fa0cc85
commit
892bfb9df0
@@ -30,6 +30,9 @@ WSJTX_CONF="$HOME/.var/app/$WSJTX_FLATPAK/config/WSJT-X.ini"
|
||||
JS8CALL_CONF="$CONFIG_HOME/JS8Call.ini"
|
||||
PAT_CONF="$CONFIG_HOME/pat/config.json"
|
||||
FLDIGI_CONF="$HOME/.fldigi/fldigi_def.xml"
|
||||
NOT1MM_CONF="$CONFIG_HOME/not1mm/not1mm.json"
|
||||
QLOG_FLATPAK=io.github.foldynl.QLog
|
||||
QLOG_DB="$HOME/.var/app/$QLOG_FLATPAK/data/hamradio/QLog/qlog.db"
|
||||
DIREWOLF_CONF="$HAMPACK_STATE/conf.d/direwolf.conf"
|
||||
# What HamPack's conf.d/direwolf.conf ships with, which configure replaces
|
||||
DIREWOLF_DEFAULT_ADEVICE="plughw:0,0"
|
||||
@@ -51,8 +54,8 @@ Usage: radio [detect] [--probe]
|
||||
probe PORT Ask the radio on serial port PORT what it is
|
||||
configure Set up the radio (if there's more than one, give its number
|
||||
from \`radio\`): run rigctld for it as a systemd user service,
|
||||
and point WSJT-X, JS8Call, Pat, fldigi and Dire Wolf at
|
||||
rigctld. Only changes
|
||||
and point WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm
|
||||
and QLog at rigctld. Only changes
|
||||
settings you haven't set, and backs up each file it changes.
|
||||
Quit those programs first
|
||||
--force Replace rig settings you've set yourself
|
||||
@@ -700,6 +703,129 @@ configure_direwolf() {
|
||||
report "Dire Wolf" "$message"
|
||||
}
|
||||
|
||||
# not1mm: rig control through rigctld, unless it uses flrig, TCI or another
|
||||
# rigctld already
|
||||
configure_not1mm() {
|
||||
local tmp
|
||||
if [ ! -x "$HOME/.local/bin/not1mm" ]; then
|
||||
report not1mm "not installed"
|
||||
return
|
||||
fi
|
||||
if [ ! -f "$NOT1MM_CONF" ]; then
|
||||
report not1mm "skipped: it has no settings yet. Run not1mm once, then \`radio configure\` again"
|
||||
return
|
||||
fi
|
||||
if running not1mm; then
|
||||
report not1mm "skipped, because it's running and would overwrite its settings when it quits. Quit it and run \`radio configure\` again"
|
||||
return
|
||||
fi
|
||||
case "$(jq -r --arg addr "$RIGCTLD_ADDR" '
|
||||
if .userigctld == true and "\(.CAT_ip):\(.CAT_port)" == $addr then "done"
|
||||
elif .userigctld == true or .useflrig == true or .usetci == true then "set"
|
||||
else "unset" end' "$NOT1MM_CONF")" in
|
||||
done)
|
||||
report not1mm "already set up"
|
||||
return ;;
|
||||
set)
|
||||
if (( ! FORCE )); then
|
||||
report not1mm "left alone: it has rig control set up already. \`radio configure --force\` replaces that"
|
||||
return
|
||||
fi ;;
|
||||
unset) ;;
|
||||
*)
|
||||
report not1mm "couldn't read $NOT1MM_CONF"
|
||||
return 1 ;;
|
||||
esac
|
||||
back_up "$NOT1MM_CONF"
|
||||
tmp="$(mktemp "$NOT1MM_CONF.XXXXXX")" || return 1
|
||||
if jq --arg ip "${RIGCTLD_ADDR%:*}" --argjson port "${RIGCTLD_ADDR#*:}" '
|
||||
.userigctld = true | .useflrig = false | .usetci = false | .CAT_ip = $ip | .CAT_port = $port
|
||||
' "$NOT1MM_CONF" > "$tmp" && chmod --reference="$NOT1MM_CONF" "$tmp" && mv -f "$tmp" "$NOT1MM_CONF"; then
|
||||
report not1mm "rig control through rigctld"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
report not1mm "couldn't change $NOT1MM_CONF"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# QLog keeps its rig profiles in its log database. Add a "HamPack" profile for
|
||||
# rigctld (Hamlib's NET rigctl) and select it, if there are no profiles yet.
|
||||
# The values are those QLog 0.54's settings dialog gives a new profile. QLog
|
||||
# keeps recent changes in qlog.db-wal, so the log is backed up (to BACKUP)
|
||||
# through SQLite, which includes them. qlog_profile BACKUP prints done, kept,
|
||||
# added, old (a database without the columns these need) or the error
|
||||
qlog_profile() {
|
||||
python3 -I -c '
|
||||
import sqlite3, sys
|
||||
db, backup, host, port, force = sys.argv[1], sys.argv[2], sys.argv[3], int(sys.argv[4]), sys.argv[5] == "1"
|
||||
profile = {
|
||||
"profile_name": "HamPack", "model": 2, "port_pathname": "", "hostname": host, "netport": port,
|
||||
"baudrate": 0, "databits": 0, "stopbits": 0.0, "flowcontrol": "", "parity": "",
|
||||
"pollinterval": 500, "txfreq_start": 0.0, "txfreq_end": 0.0, "get_freq": 1, "get_mode": 1,
|
||||
"get_vfo": 1, "get_pwr": 1, "rit_offset": 0.0, "xit_offset": 0.0, "get_rit": 0, "get_xit": 0,
|
||||
"default_pwr": 100.0, "get_ptt": 0, "qsy_wiping": 1, "get_key_speed": 1, "assigned_cw_key": " ",
|
||||
"key_speed_sync": 0, "driver": 1, "dxspot2rig": 0, "ptt_type": "", "ptt_port_pathname": "",
|
||||
"rts": "", "dtr": "", "civaddr": None, "share_rigctld": 0, "rigctld_port": 4532,
|
||||
"rigctld_path": "", "rigctld_args": "", "get_split": 0, "cwkey_output": 0, "selected": 1,
|
||||
}
|
||||
try:
|
||||
con = sqlite3.connect(db)
|
||||
columns = {row[1].lower() for row in con.execute("PRAGMA table_info(rig_profiles)")}
|
||||
if not set(profile) <= columns:
|
||||
print("old")
|
||||
sys.exit(0)
|
||||
if con.execute("SELECT 1 FROM rig_profiles WHERE driver = 1 AND model = 2 AND hostname = ? AND netport = ? AND IFNULL(selected, 0) = 1",
|
||||
(host, port)).fetchone():
|
||||
print("done")
|
||||
sys.exit(0)
|
||||
if con.execute("SELECT 1 FROM rig_profiles WHERE profile_name != ?", ("HamPack",)).fetchone() and not force:
|
||||
print("kept")
|
||||
sys.exit(0)
|
||||
copy = sqlite3.connect(backup)
|
||||
con.backup(copy)
|
||||
copy.close()
|
||||
with con:
|
||||
con.execute("DELETE FROM rig_profiles WHERE profile_name = ?", ("HamPack",))
|
||||
con.execute("UPDATE rig_profiles SET selected = 0")
|
||||
con.execute("INSERT INTO rig_profiles (%s) VALUES (%s)" % (", ".join(profile), ", ".join("?" * len(profile))),
|
||||
list(profile.values()))
|
||||
print("added")
|
||||
except (sqlite3.Error, OSError) as e:
|
||||
print(e)
|
||||
' "$QLOG_DB" "$1" "${RIGCTLD_ADDR%:*}" "${RIGCTLD_ADDR#*:}" "$FORCE"
|
||||
}
|
||||
|
||||
configure_qlog() {
|
||||
local result
|
||||
if ! flatpak info "$QLOG_FLATPAK" > /dev/null 2>&1; then
|
||||
report QLog "not installed"
|
||||
return
|
||||
fi
|
||||
if [ ! -f "$QLOG_DB" ]; then
|
||||
report QLog "skipped: it has no log yet. Run QLog once, then \`radio configure\` again"
|
||||
return
|
||||
fi
|
||||
if running qlog; then
|
||||
report QLog "skipped, because it's running and would overwrite its rig profiles. Quit it and run \`radio configure\` again"
|
||||
return
|
||||
fi
|
||||
local backup
|
||||
backup="$QLOG_DB.bak-$(date +%Y%m%d-%H%M%S)"
|
||||
result="$(qlog_profile "$backup")"
|
||||
case "$result" in
|
||||
added)
|
||||
BACKUPS+=("$backup")
|
||||
report QLog "rig profile \"HamPack\" is rigctld, and selected" ;;
|
||||
done) report QLog "already set up" ;;
|
||||
kept) report QLog "left alone: it has rig profiles already. \`radio configure --force\` adds one for rigctld and selects it" ;;
|
||||
old) report QLog "skipped: its log is older than this radio knows. Open QLog once to update it, then \`radio configure\` again" ;;
|
||||
*)
|
||||
report QLog "couldn't change $QLOG_DB: $result"
|
||||
return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Write and (re)start rigctld's user service: write_rigctld NAME HAMLIB PORT BAUD
|
||||
write_rigctld() {
|
||||
local unit
|
||||
@@ -818,13 +944,15 @@ configure() {
|
||||
configure_pat
|
||||
configure_fldigi
|
||||
configure_direwolf "$card"
|
||||
configure_not1mm
|
||||
configure_qlog
|
||||
|
||||
mkdir -p "$HAMPACK_STATE" &&
|
||||
printf 'name=%s\nhamlib=%s\nport=%s\nbaud=%s\ncard=%s\n' "$name" "$model" "$port" "$baud" "$card" > "$HAMPACK_STATE/radio"
|
||||
|
||||
echo
|
||||
if [ -n "$card" ]; then
|
||||
echo "Choose the radio's sound card in each program yourself: $card, \"$(attr "${CARD_USB[$(card_of "$radio")]}" product)\"."
|
||||
echo "Choose the radio's sound card in the other programs yourself: $card, \"$(attr "${CARD_USB[$(card_of "$radio")]}" product)\"."
|
||||
else
|
||||
echo "No sound card was found with the radio: choose the one it's connected to in each program yourself."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user