hil: wmbusmeters link-layer cross-check; firmware duty-cycle accounting
This commit is contained in:
+25
@@ -103,6 +103,31 @@ if [ "$PROOF" = 1 ]; then
|
||||
$PY hil/verify_tx.py --serial "$RUN_DIR/proof_serial.log" \
|
||||
--sdr "$RUN_DIR/proof_sdr.log" --json > "$RUN_DIR/tx_proof.json" 2>&1 || true
|
||||
cat "$RUN_DIR/tx_proof.txt"
|
||||
|
||||
# Second, independent decoder opinion on one of our transmitted frames:
|
||||
# rtl-wmbus proves it demodulates, wmbusmeters proves the link layer is
|
||||
# a structurally valid wM-Bus telegram.
|
||||
FRAME=$(grep -o '"raw":"[0-9A-Fa-f]*"' "$RUN_DIR/proof_serial.log" \
|
||||
| head -1 | sed 's/.*"raw":"//;s/"//')
|
||||
if [ -n "${FRAME:-}" ]; then
|
||||
COOKED=$($PY - "$FRAME" <<'PYCOOK'
|
||||
import sys
|
||||
sys.path.insert(0, "hil")
|
||||
from correlate import cook_a
|
||||
raw = bytes.fromhex(sys.argv[1])
|
||||
c = cook_a(raw)
|
||||
print(c.hex() if c else "")
|
||||
PYCOOK
|
||||
)
|
||||
if [ -n "$COOKED" ]; then
|
||||
if ./hil/verify_frame_semantics.sh "$COOKED" \
|
||||
"$RUN_DIR/frame_semantics.txt"; then
|
||||
echo "wmbusmeters link-layer cross-check: PASS"
|
||||
else
|
||||
echo "wmbusmeters link-layer cross-check: FAIL (see frame_semantics.txt)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- phase B: real meter traffic, decodes + IQ from ONE stream -------------
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Independent semantic check of a transmitted frame using wmbusmeters.
|
||||
#
|
||||
# rtl-wmbus proves the PHY/framing is demodulable and the CRCs are right.
|
||||
# wmbusmeters is a separate implementation with its own link-layer parser,
|
||||
# so agreeing with it shows the frame is a structurally valid Wireless M-Bus
|
||||
# telegram (manufacturer, ID, version, device type, CI field) and not merely
|
||||
# something that happens to satisfy a CRC.
|
||||
#
|
||||
# Usage: verify_frame_semantics.sh COOKED_HEX [OUTFILE]
|
||||
# Exit 0 if wmbusmeters parsed the link layer, 1 otherwise.
|
||||
set -euo pipefail
|
||||
HEX=$1
|
||||
OUT=${2:-/dev/stdout}
|
||||
|
||||
if ! command -v wmbusmeters >/dev/null 2>&1; then
|
||||
echo "wmbusmeters not on PATH; skipping semantic cross-check" > "$OUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ANALYSIS=$(wmbusmeters --analyze "$HEX" 2>&1 || true)
|
||||
echo "$ANALYSIS" > "$OUT"
|
||||
|
||||
# Require the link-layer fields to have been recognised.
|
||||
for field in "dll-mfct" "dll-id" "dll-version" "dll-type" "tpl-ci-field"; do
|
||||
if ! grep -q "$field" <<< "$ANALYSIS"; then
|
||||
echo "MISSING: $field" >> "$OUT"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
Reference in New Issue
Block a user