Update HIL verification for hop-marked repeats

This commit is contained in:
Lars Nolden
2026-09-21 12:31:19 +02:00
parent a11a4b3b89
commit 8c44c54131
13 changed files with 525 additions and 309 deletions
+23 -10
View File
@@ -37,6 +37,11 @@ while [ $# -gt 0 ]; do
esac
done
if ! [[ "$TXPOW" =~ ^-?[0-9]+$ ]] || (( TXPOW < -9 || TXPOW > 2 )); then
echo "--tx-power must be an integer in -9..2" >&2
exit 2
fi
PY=./result-py/bin/python3
[ -x "$PY" ] || { echo "run 'nix build .#hil-python -o result-py' first" >&2; exit 2; }
@@ -154,21 +159,29 @@ cat "$RUN_DIR/final_stats.log" >> "$RUN_DIR/serial.log"
# --- RF-level repeat proof from the same stream's IQ ----------------------
if [ -s "$IQ" ]; then
echo "RF-level repeat proof from captured IQ"
$PY hil/verify_repeats_iq.py --iq "$IQ" --serial "$RUN_DIR/serial.log" \
--delay-ms "$DELAY" > "$RUN_DIR/iq_proof.txt" 2>&1 || true
$PY hil/verify_repeats_iq.py --iq "$IQ" --serial "$RUN_DIR/serial.log" \
--delay-ms "$DELAY" --json > "$RUN_DIR/iq_proof.json" 2>&1 || true
cat "$RUN_DIR/iq_proof.txt"
# IQ is large: keep it only when the proof failed, for offline inspection
if grep -q '"tx_events_with_rf": [1-9]' "$RUN_DIR/iq_proof.json" 2>/dev/null; then
echo "RF-level repeat proof from meter-anchored IQ"
RF_RC=0
if ! $PY hil/meter_anchored.py --iq "$IQ" \
--serial "$RUN_DIR/serial.log" --json \
> "$RUN_DIR/rf_proof.json" 2> "$RUN_DIR/rf_proof.err"; then
RF_RC=$?
fi
if [ -s "$RUN_DIR/rf_proof.json" ]; then
cat "$RUN_DIR/rf_proof.json"
else
cat "$RUN_DIR/rf_proof.err"
fi
# Preserve weak, absent and unclassifiable RF for offline audit.
if [ "$RF_RC" = "0" ] \
&& grep -q '"rf_state": "strong"' "$RUN_DIR/rf_proof.json" 2>/dev/null; then
rm -f "$IQ"
fi
fi
# --- 13-14. correlate ------------------------------------------------------
MAXDELAY=$(awk "BEGIN{printf \"%.3f\", ($DELAY + 200) / 1000}")
$PY hil/correlate.py --serial "$RUN_DIR/serial.log" --sdr "$RUN_DIR/rtlwmbus.log" \
--min-delay 0.010 --max-delay 0.400 > "$RUN_DIR/report.json"
--min-delay 0.010 --max-delay "$MAXDELAY" > "$RUN_DIR/report.json"
# --- 15. lockup / reset detection -----------------------------------------
HB=$(grep -c '"event":"heartbeat"' "$RUN_DIR/serial.log" || true)
@@ -189,7 +202,7 @@ $PY hil/report.py "$RUN_DIR/report.json" \
--sdr-streamed "$STREAMED" \
--sdr-sensitivity "${SENS:-unknown}" \
--tx-proof "$RUN_DIR/tx_proof.json" \
--iq-proof "$RUN_DIR/iq_proof.json" \
--rf-proof "$RUN_DIR/rf_proof.json" \
| tee "$RUN_DIR/report.txt"
RC=${PIPESTATUS[0]}
echo "artifacts: $RUN_DIR"