hil: SDR health gate, TX decodability proof phase, richer report

This commit is contained in:
Lars Nolden
2026-09-01 08:27:50 +02:00
parent 0df784525a
commit a422305059
5 changed files with 338 additions and 69 deletions
+64 -33
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
"""Render a human-readable HIL report from correlate.py JSON.
Usage: report.py report.json [--min-repeats N] [--min-rx-rate PCT]
Usage: report.py report.json [options]
Exit code 0 = PASS, 1 = FAIL.
"""
import argparse
import json
import os
import sys
ap = argparse.ArgumentParser()
@@ -17,70 +18,99 @@ ap.add_argument("--min-rx-rate", type=float, default=0,
ap.add_argument("--duration", type=float, default=0)
ap.add_argument("--tx-power", default="?")
ap.add_argument("--repeat-delay", default="?")
ap.add_argument("--sdr-streamed", default="?")
ap.add_argument("--tx-proof", default=None)
args = ap.parse_args()
r = json.load(open(args.report))
d = r.get("repeat_delay_ms") or {}
fw = r.get("firmware_events") or {}
fail_reasons = []
proof = None
if args.tx_proof and os.path.exists(args.tx_proof):
try:
proof = json.load(open(args.tx_proof))
except (json.JSONDecodeError, OSError):
proof = None
def fmt(v, unit=""):
if v is None:
return "n/a"
if isinstance(v, float):
return f"{v:.1f}{unit}"
return f"{v}{unit}"
fail = []
if r.get("sdr_originals", 0) == 0:
fail_reasons.append("SDR saw no original meter frames")
fail.append("SDR observed no original meter frames")
if r.get("heltec_rx", 0) == 0:
fail_reasons.append("Heltec received nothing")
fail.append("Heltec received nothing")
if r.get("sdr_repeats", 0) < args.min_repeats:
fail_reasons.append(
f"SDR-verified repeats {r.get('sdr_repeats', 0)} < {args.min_repeats}")
fail.append(f"SDR-verified repeats {r.get('sdr_repeats', 0)} < {args.min_repeats}")
if args.min_rx_rate and (r.get("rx_match_rate_pct") or 0) < args.min_rx_rate:
fail_reasons.append("RX match rate below threshold")
fail.append("RX match rate below threshold")
if fw.get("boots", 0) > 1:
fail_reasons.append(f"unexpected MCU resets: {fw.get('boots', 0) - 1}")
fail.append(f"unexpected MCU resets: {fw['boots'] - 1}")
if proof is not None and proof.get("bursts_with_sdr_decode", 0) == 0:
fail.append("SDR could not decode any Heltec C1 transmission")
verdict = "PASS" if not fail_reasons else "FAIL"
verdict = "PASS" if not fail else "FAIL"
W = 50
print("=" * W)
print("=" * 50)
print("SOLENOS WMBUS HIL TEST")
print("=" * W)
print("=" * 50)
print(f"""
DUT:
Heltec WiFi LoRa 32 V4.3 (HTIT-WB32LAF)
ESP32-S3 + SX1262 + KCT8103L FEM
RF:
frequency: 868.950 MHz
mode: C1
configured TX power: {args.tx_power} dBm
mode: C1 (2-FSK, 100 kbps, +/-45 kHz)
configured TX power: {args.tx_power} dBm (SX1262; external PA adds gain)
repeat delay: {args.repeat_delay} ms
TEST:
duration: {args.duration:.0f} s
SDR streaming time: {args.sdr_streamed} s""")
SDR:
frames total: {r.get('sdr_frames_total')}
C1 CRC-ok: {r.get('sdr_c1_crc_ok')}
originals: {r.get('sdr_originals')}
if proof is not None:
print(f"""
TX DECODABILITY PROOF (synthetic C1, independent of meters):
bursts transmitted: {proof.get('bursts_requested')}
firmware TX ok: {proof.get('tx_reported_ok')}
SDR decoded as C1: {proof.get('bursts_with_sdr_decode')}
both airings decoded: {proof.get('bursts_with_both_airings_decoded')}""")
print(f"""
SDR (independent observer):
decode lines: {r.get('sdr_frames_total')}
C1 CRC-ok bursts: {r.get('sdr_c1_crc_ok')}
classified originals: {r.get('sdr_originals')}
classified repeats: {r.get('sdr_repeats')}
unique meters: {len(r.get('per_meter') or {})}
HELTEC RX:
frames: {r.get('heltec_rx')}
crc ok: {r.get('heltec_rx_crc_ok')}
matched originals: {r.get('rx_matched')}
match rate: {r.get('rx_match_rate_pct')} %
CRC ok: {r.get('heltec_rx_crc_ok')}
matched SDR originals: {r.get('rx_matched')}
match rate: {fmt(r.get('rx_match_rate_pct'), ' %')}
HELTEC TX:
attempts: {r.get('heltec_tx_attempts')}
reported success: {r.get('heltec_tx_ok')}
SDR VERIFIED REPEATS:
matched: {r.get('sdr_repeats')}
SDR-VERIFIED REPEATS:
byte-identical pairs: {r.get('sdr_repeats')}
fully correlated: {r.get('fully_correlated_repeats')}
success rate: {r.get('repeat_success_rate_pct')} %
vs TX attempts: {fmt(r.get('repeat_success_rate_pct'), ' %')}
TIMING:
median repeat delay: {d.get('median')} ms
minimum: {d.get('min')} ms
maximum: {d.get('max')} ms
TIMING (SDR-observed original -> repeat):
median: {fmt(d.get('median'), ' ms')}
minimum: {fmt(d.get('min'), ' ms')}
maximum: {fmt(d.get('max'), ' ms')}
ERRORS:
radio recoveries: {fw.get('recoveries')}
@@ -89,14 +119,15 @@ ERRORS:
if r.get("per_meter"):
print(f"{'METER':>10} {'SDR':>6} {'HELTEC':>7} {'MATCHED':>8}")
for m, v in sorted(r["per_meter"].items()):
for m, v in sorted(r["per_meter"].items(),
key=lambda kv: -kv[1]["sdr"]):
print(f"{m:>10} {v['sdr']:>6} {v['heltec']:>7} {v['matched']:>8}")
print()
if fail_reasons:
if fail:
print("FAIL REASONS:")
for fr in fail_reasons:
print(f" - {fr}")
for f in fail:
print(f" - {f}")
print()
print(f"RESULT:\n {verdict}")