simplified message handling, switch from XOR checksum to CRC8 with polynomial 0x97.

0x97 allows for detection of all 1-3 bit errors in a message of up to
119 bytes
(see https://www.faa.gov/aircraft/air_cert/design_approvals/air_software/media/TC-14-49.pdf)
This commit is contained in:
Martin Preuss
2023-04-07 23:22:40 +02:00
parent 4e1f08b567
commit 7eb462173c
33 changed files with 281 additions and 367 deletions

View File

@@ -31,12 +31,12 @@
.equ CPRO_PAYLOAD_FLAGS_SECONDS = 0x01
.equ CPRO_PAYLOAD_FLAGS_UID = 0x02
.equ CPRO_PAYLOAD_FLAGS_RESERVED1 = 0x04
.equ CPRO_PAYLOAD_FLAGS_RESERVED2 = 0x08
.equ CPRO_PAYLOAD_FLAGS_RESERVED3 = 0x10
.equ CPRO_PAYLOAD_FLAGS_NUM0 = 0x20
.equ CPRO_PAYLOAD_FLAGS_NUM1 = 0x40
.equ CPRO_PAYLOAD_FLAGS_NUM3 = 0x80
.equ CPRO_PAYLOAD_FLAGS_SHIFT_NUM = 5
.equ CPRO_PAYLOAD_FLAGS_NUM0 = 0x08
.equ CPRO_PAYLOAD_FLAGS_NUM1 = 0x10
.equ CPRO_PAYLOAD_FLAGS_NUM2 = 0x20
.equ CPRO_PAYLOAD_FLAGS_NUM3 = 0x40
.equ CPRO_PAYLOAD_FLAGS_NUM4 = 0x80
.equ CPRO_PAYLOAD_FLAGS_SHIFT_NUM = 3
.equ CPRO_PACKET_HAVEADDR_OFFS_ADDRESS = COM_MSG_OFFS_PAYLOAD+4
@@ -244,7 +244,7 @@ cproEnqueueMsgWithCmdAndSrcAddr:
pop r20
pop xl
pop xh
rcall comCalcAndAddChecksumByte
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
; mark buffer as enqueued with PRIO given in R20
rcall COM_EnqueuePacket ; (R15, R16)
@@ -331,9 +331,7 @@ cproCalcPayloadSize_l1:
brcc cproCalcPayloadSize_l2
add r4, r17 ; add 4 bytes
cproCalcPayloadSize_l2:
lsr r16
lsr r16
lsr r16 ; after this R16 contains CPRO_PAYLOAD_FLAGS_NUM0-3
lsr r16 ; shift out reserved1, after this R16 contains CPRO_PAYLOAD_FLAGS_NUM0-4
add r16, r4 ; add previous bytes to R16
ret