Fix Morse decoder scope events not reaching frontend

Replace blocking rtl_stdout.read() with select()+os.read() so the
decoder thread emits diagnostic heartbeat scope events when rtl_fm
produces no PCM data (common in direct sampling mode). Add waiting-state
rendering in the scope canvas and hide the generic placeholder/status
bar for morse mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-26 09:30:58 +00:00
parent 2eea28da05
commit c0c066904c
4 changed files with 79 additions and 3 deletions
+21 -1
View File
@@ -7,7 +7,9 @@ from __future__ import annotations
import contextlib
import math
import os
import queue
import select
import struct
import threading
import time
@@ -284,8 +286,26 @@ def morse_decoder_thread(
)
try:
fd = rtl_stdout.fileno()
while not stop_event.is_set():
data = rtl_stdout.read(CHUNK)
ready, _, _ = select.select([fd], [], [], 2.0)
if not ready:
# No data from SDR — emit diagnostic heartbeat
now = time.monotonic()
if now - last_scope >= SCOPE_INTERVAL:
last_scope = now
with contextlib.suppress(queue.Full):
output_queue.put_nowait({
'type': 'scope',
'amplitudes': [],
'threshold': 0,
'tone_on': False,
'waiting': True,
})
continue
data = os.read(fd, CHUNK)
if not data:
break