98 lines
3.1 KiB
Python
Executable File
98 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Summarise a long firmware reliability soak (hil/soak.sh)."""
|
|
import json
|
|
import sys
|
|
from collections import Counter
|
|
|
|
path = sys.argv[1]
|
|
duration = float(sys.argv[2]) if len(sys.argv) > 2 else 0
|
|
|
|
rx, tx, hb, rec, boots = [], [], [], [], 0
|
|
stats = None
|
|
for line in open(path, errors="replace"):
|
|
line = line.strip()
|
|
if not line.startswith("{"):
|
|
continue
|
|
try:
|
|
ev = json.loads(line)
|
|
except json.JSONDecodeError:
|
|
continue
|
|
e = ev.get("event")
|
|
if e == "wmbus_rx":
|
|
rx.append(ev)
|
|
elif e == "wmbus_tx":
|
|
tx.append(ev)
|
|
elif e == "heartbeat":
|
|
hb.append(ev)
|
|
elif e == "radio_recovery":
|
|
rec.append(ev)
|
|
elif e == "boot":
|
|
boots += 1
|
|
elif e == "stats":
|
|
stats = ev
|
|
|
|
tx_ok = [t for t in tx if str(t.get("result", "")).startswith("ok")]
|
|
delays = sorted(t["delay_us"] / 1000.0 for t in tx_ok if t.get("delay_us"))
|
|
air = sorted(t["airtime_us"] / 1000.0 for t in tx_ok if t.get("airtime_us"))
|
|
results = Counter(t.get("result") for t in tx)
|
|
uptimes = [h.get("uptime_us", 0) for h in hb]
|
|
cfg_bad = sum(1 for h in hb if h.get("config_intact") is False)
|
|
mode_bad = sum(1 for h in hb if h.get("chip_mode") not in (5, None))
|
|
|
|
|
|
def s(v, unit=""):
|
|
if not v:
|
|
return "n/a"
|
|
return (f"min={v[0]:.3f}{unit} median={v[len(v)//2]:.3f}{unit} "
|
|
f"max={v[-1]:.3f}{unit}")
|
|
|
|
|
|
print("=" * 56)
|
|
print("REPEATER RELIABILITY SOAK")
|
|
print("=" * 56)
|
|
print(f"""
|
|
requested duration: {duration:.0f} s
|
|
heartbeats: {len(hb)}
|
|
firmware uptime at end: {max(uptimes)/1e6 if uptimes else 0:.0f} s
|
|
MCU boots seen: {boots} (>1 means an unexpected reset)
|
|
|
|
RX:
|
|
candidate frames: {len(rx)}
|
|
CRC-valid frames: {sum(1 for r in rx if r.get('crc_ok'))}
|
|
|
|
TX (repeats):
|
|
attempts: {len(tx)}
|
|
success: {len(tx_ok)}
|
|
success rate: {100*len(tx_ok)/len(tx):.1f} %""" if tx else "")
|
|
|
|
if not tx:
|
|
print("TX: no repeat events recorded")
|
|
|
|
print(f" result breakdown: {dict(results)}")
|
|
print(f" repeat delay: {s(delays, ' ms')}")
|
|
print(f" TX airtime: {s(air, ' ms')}")
|
|
print(f"""
|
|
HEALTH:
|
|
radio recoveries: {len(rec)}
|
|
heartbeats not in RX: {mode_bad}
|
|
heartbeats config lost:{cfg_bad}""")
|
|
if rec:
|
|
print(f" recovery reasons: {dict(Counter(r.get('reason') for r in rec))}")
|
|
print(f" recovery results: {dict(Counter(r.get('result') for r in rec))}")
|
|
|
|
if stats:
|
|
print("\nFIRMWARE COUNTERS (final):")
|
|
for k in ("rx_candidates", "rx_valid", "rx_crc_fail", "rx_not_c1",
|
|
"rx_len_invalid", "rx_bytes", "tx_attempts", "tx_success",
|
|
"tx_timeout", "tx_failures", "tx_suppressed_dup",
|
|
"radio_reinit", "fem_reinit", "recoveries"):
|
|
if k in stats:
|
|
print(f" {k:22s} {stats[k]}")
|
|
|
|
# milestones from the task description
|
|
n = len(tx_ok)
|
|
print("\nMILESTONES (firmware-reported repeats, no restart):")
|
|
for label, target in (("A", 10), ("B", 100), ("C", 500), ("D", 1000)):
|
|
ok = n >= target and boots <= 1
|
|
print(f" {label} (>= {target:4d}): {'REACHED' if ok else 'not reached'} ({n})")
|