fix: Update CRC calc to use 0 init and full 16-bit stored value
This commit is contained in:
@@ -82,8 +82,9 @@ class Page:
|
|||||||
Row 0: Skips first 8 bytes (Header/Control). Uses bytes 8-39.
|
Row 0: Skips first 8 bytes (Header/Control). Uses bytes 8-39.
|
||||||
Rows 1-23: Uses all 40 bytes.
|
Rows 1-23: Uses all 40 bytes.
|
||||||
Data is 7-bit (stripped parity).
|
Data is 7-bit (stripped parity).
|
||||||
|
Initial value: 0 (ETSI EN 300 706 9.4.1.2).
|
||||||
"""
|
"""
|
||||||
crc = 0xFFFF
|
crc = 0
|
||||||
poly = 0x1021
|
poly = 0x1021
|
||||||
|
|
||||||
# Helper to update CRC with a byte
|
# Helper to update CRC with a byte
|
||||||
@@ -135,13 +136,13 @@ class Page:
|
|||||||
|
|
||||||
if designation == 0:
|
if designation == 0:
|
||||||
# Packet 27/0
|
# Packet 27/0
|
||||||
# Checksum is in bytes 38 and 39
|
# Checksum is in bytes 38 and 39.
|
||||||
|
# ETSI EN 300 706: 8 bits of each byte are used.
|
||||||
if len(p.data) >= 40:
|
if len(p.data) >= 40:
|
||||||
hi = p.data[38]
|
hi = p.data[38]
|
||||||
lo = p.data[39]
|
lo = p.data[39]
|
||||||
|
|
||||||
# Strip parity
|
crc = (hi << 8) | lo
|
||||||
crc = ((hi & 0x7F) << 8) | (lo & 0x7F)
|
|
||||||
return crc
|
return crc
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user