wmbus: fix format-A length formula for L=10 (mod 16); host tests under ASan

This commit is contained in:
Lars Nolden
2026-09-01 11:28:14 +02:00
parent c835c62172
commit 6bdcb2acad
6 changed files with 302 additions and 3 deletions
+13
View File
@@ -23,6 +23,19 @@ import sys
from datetime import datetime
def total_len_a(lfield: int) -> int:
"""Over-the-air length of a format A frame, incl. L and all CRC bytes.
Block 1 = L + C,M,A (10 bytes) + CRC; the remaining (L - 9) L-counted
bytes go into blocks of at most 16, each followed by 2 CRC bytes. This
matches firmware/main/wmbus.c; see the note there about rtl-wmbus
differing for L = 10 (mod 16).
"""
if lfield < 9:
return -1
return 1 + lfield + 2 * (1 + (lfield - 9 + 15) // 16)
def cook_a(frame: bytes):
"""Strip block CRCs from a format A over-the-air frame."""
if len(frame) < 12: