fix(cat): keep the Kenwood read buffer across commands; log the CAT error

A TS-480 connected, answered ID, then never reported a state:

  discarding " 000000000010000000;" while waiting for IF
  connected on COM3 @ 115200 baud
  cat:state → connected=false freq=0

A headless frame tail can only come from bytes that were thrown away.
ask() buffered into a local slice, so everything left after the matched
frame — including the head of a frame still arriving — went with it, and
the link could sit one answer behind its questions. The buffer now lives
on the backend, and Connect drains whatever the rig said before AI0 took
effect rather than inheriting it.

Also: the cat:state diagnostic prints RigState.Error. It read
"connected=false freq=0" and said nothing about why, so every report of a
CAT failure arrived without the one fact that explains it — the reason
only ever reached a tooltip.

New work moves to 0.22.8; 0.22.7 is released.
This commit is contained in:
2026-08-01 12:04:32 +02:00
parent a83acb0f9a
commit c62d992ad6
3 changed files with 82 additions and 20 deletions
+12 -2
View File
@@ -971,8 +971,18 @@ func (a *App) startup(ctx context.Context) {
// burst of these lines = the frontend is being re-rendered rapidly (the
// "screen flickers" symptom). Shows WHAT is churning — connection flap,
// or freq/split/mode oscillating between slices during FT8.
applog.Printf("cat:state → connected=%v freq=%d rx=%d split=%v mode=%s band=%s",
s.Connected, s.FreqHz, s.RxFreqHz, s.Split, s.Mode, s.Band)
// The error goes in the line too. Without it a disconnect read
// "connected=false freq=0" and said nothing about WHY — the reason was in
// RigState.Error, which only ever reached a tooltip, so every report of
// "it stopped connecting" arrived without the one fact that explains it.
applog.Printf("cat:state → connected=%v freq=%d rx=%d split=%v mode=%s band=%s%s",
s.Connected, s.FreqHz, s.RxFreqHz, s.Split, s.Mode, s.Band,
func() string {
if s.Error == "" {
return ""
}
return " err=" + s.Error
}())
if a.ctx != nil {
wruntime.EventsEmit(a.ctx, "cat:state", s)
}