hyundai: TCS13 checksum (#623)

master
Greg Hogan 2021-04-05 08:44:16 -07:00 committed by GitHub
parent d6d928125b
commit c416419c16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -94,6 +94,9 @@ static uint8_t hyundai_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) {
} else {
// sum of nibbles
for (int i = 0; i < 8; i++) {
if ((addr == 916) && (i == 7)) {
continue; // exclude
}
uint8_t b = GET_BYTE(to_push, i);
if (((addr == 608) && (i == 7)) || ((addr == 916) && (i == 6)) || ((addr == 1057) && (i == 7))) {
b &= (addr == 1057) ? 0x0FU : 0xF0U; // remove checksum

View File

@ -41,6 +41,8 @@ def checksum(msg):
b &= 0x0F if addr == 1057 else 0xF0
elif addr == 916 and i == 6:
b &= 0xF0
elif addr == 916 and i == 7:
continue
chksum += sum(divmod(b, 16))
chksum = (16 - chksum) % 16
ret = bytearray(dat)