hil: wmbusmeters link-layer cross-check; firmware duty-cycle accounting

This commit is contained in:
Lars Nolden
2026-09-01 11:31:26 +02:00
parent 697e10e8cf
commit 6633cd6f92
4 changed files with 67 additions and 2 deletions
+31
View File
@@ -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