From 2dd0dfa302b80b613474076ff93b5a5680d0ba29 Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Wed, 18 Mar 2026 13:12:10 +0100 Subject: [PATCH] Add ws debug logs and fix classifier/recorder issues --- cmd/sdrd/main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/sdrd/main.go b/cmd/sdrd/main.go index c398d79..a49b7aa 100644 --- a/cmd/sdrd/main.go +++ b/cmd/sdrd/main.go @@ -49,8 +49,10 @@ type client struct { } type hub struct { - mu sync.Mutex - clients map[*client]struct{} + mu sync.Mutex + clients map[*client]struct{} + frameCnt int64 + lastLogTs time.Time } type gpuStatus struct { @@ -95,13 +97,14 @@ func (g *gpuStatus) snapshot() gpuStatus { } func newHub() *hub { - return &hub{clients: map[*client]struct{}{}} + return &hub{clients: map[*client]struct{}{}, lastLogTs: time.Now()} } func (h *hub) add(c *client) { h.mu.Lock() defer h.mu.Unlock() h.clients[c] = struct{}{} + log.Printf("ws connected (%d clients)", len(h.clients)) } func (h *hub) remove(c *client) { @@ -109,6 +112,7 @@ func (h *hub) remove(c *client) { h.mu.Lock() defer h.mu.Unlock() delete(h.clients, c) + log.Printf("ws disconnected (%d clients)", len(h.clients)) } func (h *hub) broadcast(frame SpectrumFrame) { @@ -132,6 +136,11 @@ func (h *hub) broadcast(frame SpectrumFrame) { h.remove(c) } } + h.frameCnt++ + if time.Since(h.lastLogTs) > 2*time.Second { + h.lastLogTs = time.Now() + log.Printf("broadcast frames=%d clients=%d", h.frameCnt, len(clients)) + } } type sourceManager struct { @@ -323,6 +332,7 @@ func main() { RecordAudio: cfg.Recorder.RecordAudio, AutoDemod: cfg.Recorder.AutoDemod, AutoDecode: cfg.Recorder.AutoDecode, + MaxDiskMB: cfg.Recorder.MaxDiskMB, OutputDir: cfg.Recorder.OutputDir, ClassFilter: cfg.Recorder.ClassFilter, RingSeconds: cfg.Recorder.RingSeconds, @@ -372,6 +382,7 @@ func main() { case <-ping.C: _ = conn.SetWriteDeadline(time.Now().Add(5 * time.Second)) if err := conn.WriteMessage(websocket.PingMessage, nil); err != nil { + log.Printf("ws ping error: %v", err) return } }