wmbus: fix format-A length formula for L=10 (mod 16); host tests under ASan
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user