feat: panadapter spots that read, a CI-V link that survives, no auto-call

Panadapter spots are now worth reading. The comment carries the spotter, the
entity and the status in DXHunter's own shape — "CQ up 2 [F4BPO] [Franz Josef
Land] [New Slot]" — which needed two things nothing documents: SmartSDR splits
its command line on SPACES, so the words ran together until every space became
non-breaking; and it truncates past ~60 characters, so the cluster's own words
are trimmed first and the three brackets always survive. RBN column padding is
collapsed on the way in, or a preserved run of spaces opened a gap wide enough
to push the rest off screen.

"Already worked" means the CALLSIGN is in the log, not the entity: saying it of
a station never contacted was simply wrong. Each status can also be kept off the
panadapter entirely, and the WSJT-X decode spots obey the same switches — the
palette governs the panadapter, not one of the two things that feed it.

And the radio is no longer hammered: a spot whose frequency, colour and comment
are unchanged is not removed and redrawn. A busy skimmer feed re-spots the same
station every few seconds; one two-minute session sent 2128 adds, 88 of them for
a single callsign, and the display did not move a pixel for any of them.

CI-V, from an IC-7850 that kept killing JTDX: a reply the rig sent to another
controller on the same bus is no longer taken for ours, and a set_ptt, set_freq
or set_mode whose acknowledgement goes missing is verified by reading the rig
back instead of being reported as a failure. WSJT-X and JTDX answer a failed
command with a Rig Control Error and drop the link mid-over — 98 keyings, 6 lost
acknowledgements, 2 dropped connections in one session. The check waits 700 ms,
not the poll's 150: the rig has just failed to answer twice because it was
retuning, and a short probe would fail for the same reason.

Auto-call is withdrawn — it duplicated DXHunter, which already answers decodes,
and two programs deciding that from one shack key over each other. The library
is kept whole and dormant; a guard in App.tsx makes sure a stored preference
cannot key a transmitter whose switch no longer exists.

Also:
  - the log rotates while running, not only at startup: the CI-V trace left on
    wrote 416 MB and nothing would have stopped it before the disk did. Closing
    it now releases the crash file too — the runtime keeps its own duplicate.
  - the interface zoom announces itself, with a badge, a click back to 100% and
    a View menu; Ctrl+wheel and Ctrl+0 always worked and nothing said so.
  - no more elastic bounce, and no swipe-to-navigate out of the app.
  - Edit QSO: your own TX power and the contacted station's extended locator
    were saved and written back with no box to set them.
  - FT decodes: continents are a multiple choice; a compound MSHV message that
    answers two stations in one line is recognised as addressed to you.
This commit is contained in:
2026-08-23 01:16:26 +02:00
parent bcfb3bfd37
commit f50806fbd9
17 changed files with 829 additions and 209 deletions
+87 -7
View File
@@ -514,8 +514,21 @@ func (b *IcomSerial) SetFrequency(hz int64) error {
return fmt.Errorf("invalid frequency")
}
b.lastSetFreq, b.lastSetFreqAt = hz, time.Now()
return b.execIdempotent(fmt.Sprintf("set frequency %d Hz", hz),
err := b.execIdempotent(fmt.Sprintf("set frequency %d Hz", hz),
append([]byte{civ.CmdSetFreq}, civ.FreqToBCD(hz)...)...)
// Same reasoning as SetPTT: a lost acknowledgement is not a failed command,
// and WSJT-X or JTDX answer a failed set_freq by dropping the link — an
// IC-7850 log shows exactly that at 15:16:15, the disconnect four seconds
// later. The rig is asked what frequency it is on rather than being called a
// failure on the strength of a missing "FB".
if err == nil || !errors.Is(err, errIcomAckLost) {
return err
}
if got, rerr := b.readFreq(); rerr == nil && got == hz {
applog.Printf("icom: frequency %d Hz not acknowledged, but the rig is on it — treating as done", hz)
return nil
}
return err
}
func (b *IcomSerial) SetMode(mode string) error {
@@ -526,7 +539,16 @@ func (b *IcomSerial) SetMode(mode string) error {
// Set the base mode (keeping the rig's current filter by sending only the
// mode byte), then set the data-mode flag for digital modes.
if err := b.execIdempotent("set mode "+mode, civ.CmdSetMode, code); err != nil {
return err
// A lost acknowledgement is not a refused mode — see SetPTT. The mode is
// readable, so ask rather than report a failure that would cost the
// digital application its connection.
if !errors.Is(err, errIcomAckLost) {
return err
}
if got, ok := b.readMode(); !ok || got != code {
return err
}
applog.Printf("icom: mode %s not acknowledged, but the rig reports it — treating as done", mode)
}
dataByte := byte(0)
if data {
@@ -569,12 +591,43 @@ func (b *IcomSerial) execIdempotent(what string, payload ...byte) error {
}
// SetPTT keys or unkeys the transmitter (CI-V 0x1C 0x00).
// A lost acknowledgement is NOT proof the rig ignored us, and treating it as one
// is expensive: OpsLog fronts a Hamlib rigctl port, so the failure is handed
// straight to WSJT-X or JTDX, which answer a failed set_ptt with a Rig Control
// Error and drop the link mid-over. An IC-7850 log showed exactly that, three
// times in a session, on a CI-V bus with a second controller corrupting frames.
//
// So when the acknowledgement does not arrive, ASK the rig what it is doing. PTT
// is readable (0x1C 0x00), the answer is unambiguous, and a rig that is keyed
// received the command whatever became of its reply.
func (b *IcomSerial) SetPTT(on bool) error {
state := byte(0)
if on {
state = 1
}
return b.execIdempotent(fmt.Sprintf("PTT %v", on), civ.CmdPTT, civ.SubPTT, state)
err := b.execIdempotent(fmt.Sprintf("PTT %v", on), civ.CmdPTT, civ.SubPTT, state)
if err == nil || !errors.Is(err, errIcomAckLost) {
return err
}
// A GENEROUS window for the verification, not the poll's 150 ms.
//
// The rig has just failed to answer twice in 800 ms, and the reason seen on a
// real IC-7850 is that it was retuning: JTDX moves the transmit frequency and
// keys in the same breath. Asking it again with the short probe timeout would
// fail for exactly the same reason and prove nothing.
keyed, ok := b.readTXWithin(icomPTTVerifyTimeout)
if ok && keyed == on {
applog.Printf("icom: PTT %v not acknowledged, but the rig reports it — treating as done", on)
return nil
}
// Logged either way, because "the fix did not work" and "the rig really did
// not key" look identical from outside and need telling apart.
if ok {
applog.Printf("icom: PTT %v not acknowledged, and the rig reports %v — reporting the failure", on, keyed)
} else {
applog.Printf("icom: PTT %v not acknowledged, and the rig did not answer the check either", on)
}
return err
}
// SetPower turns the transceiver on or off (CI-V 0x18). Power-ON is prefixed with
@@ -686,6 +739,19 @@ func (b *IcomSerial) reader(port civTransport, done chan struct{}) {
if f.From != b.rigAddr {
continue // echo of our own command
}
// Addressed to US, or broadcast.
//
// A CI-V bus can carry a second controller — RS-BA1, wfview, another
// logger — and the rig answers each of them in turn on the same wire.
// Those replies come FROM the rig, so the check above lets them through,
// and one can be taken for the answer to our own command: an IC-7850 log
// showed "FE FE 01 8E …" (to controller 01) arriving between our PTT
// command and its acknowledgement, with bus collisions around it.
// Transceive broadcasts (to 0x00) stay welcome — that is how the rig
// announces a knob turn.
if f.To != civ.AddrController && f.To != 0x00 {
continue
}
if f.Cmd == civ.CmdScope {
b.route(b.specCh, f)
continue
@@ -1273,16 +1339,30 @@ func (b *IcomSerial) readTXFreq() (int64, bool) {
// readTX reads the transmit state (CI-V 0x1C 0x00): non-zero data = keyed.
func (b *IcomSerial) readTX() bool {
on, _ := b.readTXWithin(icomDSPTimeout)
return on
}
// icomPTTVerifyTimeout is how long the PTT check waits. Long, deliberately: it
// runs only after a command was already given up on, so it costs nothing in the
// normal case and everything depends on it in the abnormal one.
const icomPTTVerifyTimeout = 700 * time.Millisecond
// readTXWithin reads the transmit state, reporting whether the rig ANSWERED.
//
// The two are different questions and the caller usually needs both: "not
// transmitting" and "did not say" are the same bool but not the same fact.
func (b *IcomSerial) readTXWithin(timeout time.Duration) (on bool, answered bool) {
if err := b.write(civ.CmdPTT, civ.SubPTT); err != nil {
return false
return false, false
}
f, err := b.recv(icomDSPTimeout, func(d civ.Decoded) bool {
f, err := b.recv(timeout, func(d civ.Decoded) bool {
return d.Cmd == civ.CmdPTT && len(d.Data) >= 2 && d.Data[0] == civ.SubPTT
})
if err != nil {
return false
return false, false
}
return f.Data[1] != 0
return f.Data[1] != 0, true
}
// readMeter reads a meter (CI-V 0x15) and returns it scaled to 0-100.