hil: IQ repeat proof phase, 3-level SDR sensitivity, proof-gain option

This commit is contained in:
Lars Nolden
2026-09-01 09:03:19 +02:00
parent 78a8635ac8
commit 3fea191008
4 changed files with 239 additions and 14 deletions
+24 -6
View File
@@ -34,9 +34,17 @@ FS = 1_600_000
NS = 480_000 # 0.3 s
NFFT = 4096
RAILED_DB = 25.0 # mean power above this => railed/bypassed
MIN_SPAN_DB = 12.0 # averaged-spectrum structure
MIN_GAIN_DELTA_DB = 3.0 # noise must track tuner gain
# Reference measurements on this dongle at 868.95 MHz, 1.6 Msps:
# fresh replug (fully healthy) : mean@42.1 ~ +22 dB, span ~ 51 dB, delta ~ 25 dB
# after minutes of streaming : mean@42.1 ~ +5 dB, span ~ 21 dB, delta ~ 8 dB
# wedged / bypassed : mean ~ +40 dB railed, span < 10 dB, delta ~ 0
# The middle state still decodes strong meters but loses roughly 17 dB of
# sensitivity, so it must be reported rather than silently accepted.
RAILED_DB = 25.0
MIN_SPAN_DB = 12.0 # below this the receiver is not seeing RF structure
MIN_GAIN_DELTA_DB = 3.0 # noise must track tuner gain at all
HEALTHY_SPAN_DB = 35.0 # full sensitivity reference
HEALTHY_DELTA_DB = 15.0
def measure(gain):
@@ -86,9 +94,18 @@ if hi["spectrum_span_db"] < MIN_SPAN_DB:
if delta < MIN_GAIN_DELTA_DB:
reasons.append(f"noise does not track gain: delta {delta:.1f} dB < {MIN_GAIN_DELTA_DB}")
healthy = not reasons
usable = not reasons
if not usable:
level = "deaf"
elif (hi["spectrum_span_db"] >= HEALTHY_SPAN_DB
and delta >= HEALTHY_DELTA_DB):
level = "full"
else:
level = "degraded"
result = {
"health": "ok" if healthy else "deaf",
"health": "ok" if usable else "deaf",
"sensitivity": level,
"low": lo, "high": hi,
"gain_delta_db": round(delta, 2),
"reasons": reasons,
@@ -98,6 +115,7 @@ if args.json:
print(json.dumps(result))
else:
print(f"SDR_HEALTH={result['health']}")
print(f"SDR_SENSITIVITY={level}")
print(f"SDR_MEAN_POWER_20DB={lo['mean_power_db']:.2f}")
print(f"SDR_MEAN_POWER_42DB={hi['mean_power_db']:.2f}")
print(f"SDR_SPECTRUM_SPAN_DB={hi['spectrum_span_db']:.2f}")
@@ -105,4 +123,4 @@ else:
for r in reasons:
print(f"SDR_REASON={r}")
sys.exit(0 if healthy else 2)
sys.exit(0 if usable else 2)