mirror of
https://github.com/smittix/intercept.git
synced 2026-06-16 09:29:45 -07:00
Fix Morse mode HF reception, stop button, and UX guidance
Enable direct sampling (-D 2) for RTL-SDR at HF frequencies below 24 MHz so rtl_fm can actually receive CW signals. Add startup health check to detect immediate rtl_fm failures. Push stopped status event from decoder thread on EOF so the frontend auto-resets. Add frequency placeholder and help text. Fix stop button silently swallowing errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import contextlib
|
||||
import queue
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
from flask import Blueprint, Response, jsonify, request
|
||||
@@ -113,6 +114,9 @@ def start_morse() -> Response:
|
||||
sample_rate = 8000
|
||||
bias_t = data.get('bias_t', False)
|
||||
|
||||
# RTL-SDR needs direct sampling mode for HF frequencies below 24 MHz
|
||||
direct_sampling = 2 if freq < 24.0 else None
|
||||
|
||||
rtl_cmd = builder.build_fm_demod_command(
|
||||
device=sdr_device,
|
||||
frequency_mhz=freq,
|
||||
@@ -121,6 +125,7 @@ def start_morse() -> Response:
|
||||
ppm=int(ppm) if ppm and ppm != '0' else None,
|
||||
modulation='usb',
|
||||
bias_t=bias_t,
|
||||
direct_sampling=direct_sampling,
|
||||
)
|
||||
|
||||
full_cmd = ' '.join(rtl_cmd)
|
||||
@@ -134,6 +139,25 @@ def start_morse() -> Response:
|
||||
)
|
||||
register_process(rtl_process)
|
||||
|
||||
# Detect immediate startup failure (e.g. device busy, no device)
|
||||
time.sleep(0.35)
|
||||
if rtl_process.poll() is not None:
|
||||
stderr_text = ''
|
||||
try:
|
||||
if rtl_process.stderr:
|
||||
stderr_text = rtl_process.stderr.read().decode(
|
||||
'utf-8', errors='replace'
|
||||
).strip()
|
||||
except Exception:
|
||||
stderr_text = ''
|
||||
msg = stderr_text or f'rtl_fm exited immediately (code {rtl_process.returncode})'
|
||||
logger.error(f"Morse rtl_fm startup failed: {msg}")
|
||||
unregister_process(rtl_process)
|
||||
if morse_active_device is not None:
|
||||
app_module.release_sdr_device(morse_active_device)
|
||||
morse_active_device = None
|
||||
return jsonify({'status': 'error', 'message': msg}), 500
|
||||
|
||||
# Monitor rtl_fm stderr
|
||||
def monitor_stderr():
|
||||
for line in rtl_process.stderr:
|
||||
|
||||
Reference in New Issue
Block a user