chore(tci): cap the diagnostic logging per message type

The transmit meters are asked for four times a second while keyed, so
logging every arrival would fill an evening's log — and a diagnostic that
fills a log is one that gets switched off instead of read. Twenty of each
is enough to tell an answer from a silence, which is all it is for.
This commit is contained in:
2026-08-26 22:07:11 +02:00
parent 130c4e72e0
commit 27b342a5e7
+16 -5
View File
@@ -88,6 +88,8 @@ type TCIPanelState struct {
// arrives alongside. // arrives alongside.
type tciPanel struct { type tciPanel struct {
st TCIPanelState st TCIPanelState
// logged counts what has been written per message type — see handlePanel.
logged map[string]int
} }
// handlePanel takes the messages the console cares about. // handlePanel takes the messages the console cares about.
@@ -112,13 +114,22 @@ func (t *TCI) handlePanel(name string, get func(int) string, args string) bool {
// this is our reading or its doing, and no amount of reasoning will. // this is our reading or its doing, and no amount of reasoning will.
switch name { switch name {
case "mute", "sql_enable", "sql_level", "tx_power", "tx_swr", "tune": case "mute", "sql_enable", "sql_level", "tx_power", "tx_swr", "tune":
// Logged on arrival so an ANSWER can be told from a silence. The // Logged on arrival so an ANSWER can be told from a SILENCE: the log
// transmit meters are asked for four times a second while keyed and the // showed the transmit meters being asked for and nothing coming back,
// log showed only the asking, which proves nothing on its own: a reply // which on its own proves nothing — a reply that arrived and failed to
// that arrived and failed to parse looks exactly like one that never // parse leaves exactly the same trace as one that never came.
// came. //
// Capped per message type. The meters are asked for four times a second
// while transmitting, and a diagnostic that fills an evening's log is
// one that gets switched off instead of read.
if t.panel.logged == nil {
t.panel.logged = map[string]int{}
}
if n := t.panel.logged[name]; n < 20 {
t.panel.logged[name] = n + 1
debugLog.Printf("TCI: %s:%s", name, args) debugLog.Printf("TCI: %s:%s", name, args)
} }
}
switch name { switch name {
case "protocol": case "protocol":
p.Protocol = strings.TrimSpace(args) p.Protocol = strings.TrimSpace(args)