fix(drone): harden RFDetector threading, subprocess lifecycle, and frequency accuracy

- Replace _running bool with threading.Event for correct cross-thread visibility
- Add _proc_lock to guard _rtl_proc/_hackrf_proc across worker/main threads
- Use register_process + safe_terminate (pipe close + SIGKILL fallback on timeout)
- Compute HackRF frequency as band midpoint (hz_low+hz_high)//2, not hz_low
- Guard start() for idempotency — double-call no longer leaks threads

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-05-03 17:33:55 +01:00
parent 984f93d9f8
commit 39a9fe57bd
2 changed files with 33 additions and 18 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ def test_hackrf_sweep_line_emits_observation(detector):
obs = q.get_nowait()
assert isinstance(obs, RFObservation)
assert obs.hardware == "HACKRF"
assert obs.frequency_hz == hz_low
assert obs.frequency_hz == (hz_low + hz_high) // 2
assert obs.rssi < 0