mirror of https://github.com/commaai/panda.git
safety tests: more coverage (#1714)
* more coverage * we don't check the counter of this ford message * there are no messages with these lengths to check
This commit is contained in:
parent
5e22e87cf6
commit
55946a060d
|
@ -77,18 +77,14 @@ addr_checks ford_rx_checks = {ford_addr_checks, FORD_ADDR_CHECK_LEN};
|
|||
static uint8_t ford_get_counter(CANPacket_t *to_push) {
|
||||
int addr = GET_ADDR(to_push);
|
||||
|
||||
uint8_t cnt;
|
||||
uint8_t cnt = 0;
|
||||
if (addr == FORD_BrakeSysFeatures) {
|
||||
// Signal: VehVActlBrk_No_Cnt
|
||||
cnt = (GET_BYTE(to_push, 2) >> 2) & 0xFU;
|
||||
} else if (addr == FORD_EngVehicleSpThrottle2) {
|
||||
// Signal: VehVActlEng_No_Cnt
|
||||
cnt = (GET_BYTE(to_push, 2) >> 3) & 0xFU;
|
||||
} else if (addr == FORD_Yaw_Data_FD1) {
|
||||
// Signal: VehRollYaw_No_Cnt
|
||||
cnt = GET_BYTE(to_push, 5);
|
||||
} else {
|
||||
cnt = 0;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
@ -96,7 +92,7 @@ static uint8_t ford_get_counter(CANPacket_t *to_push) {
|
|||
static uint32_t ford_get_checksum(CANPacket_t *to_push) {
|
||||
int addr = GET_ADDR(to_push);
|
||||
|
||||
uint8_t chksum;
|
||||
uint8_t chksum = 0;
|
||||
if (addr == FORD_BrakeSysFeatures) {
|
||||
// Signal: VehVActlBrk_No_Cs
|
||||
chksum = GET_BYTE(to_push, 3);
|
||||
|
@ -107,7 +103,6 @@ static uint32_t ford_get_checksum(CANPacket_t *to_push) {
|
|||
// Signal: VehRollYawW_No_Cs
|
||||
chksum = GET_BYTE(to_push, 4);
|
||||
} else {
|
||||
chksum = 0;
|
||||
}
|
||||
return chksum;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ addr_checks hyundai_rx_checks = SET_ADDR_CHECKS(hyundai_addr_checks);
|
|||
static uint8_t hyundai_get_counter(CANPacket_t *to_push) {
|
||||
int addr = GET_ADDR(to_push);
|
||||
|
||||
uint8_t cnt;
|
||||
uint8_t cnt = 0;
|
||||
if (addr == 0x260) {
|
||||
cnt = (GET_BYTE(to_push, 7) >> 4) & 0x3U;
|
||||
} else if (addr == 0x386) {
|
||||
|
@ -101,7 +101,6 @@ static uint8_t hyundai_get_counter(CANPacket_t *to_push) {
|
|||
} else if (addr == 0x4F1) {
|
||||
cnt = (GET_BYTE(to_push, 3) >> 4) & 0xFU;
|
||||
} else {
|
||||
cnt = 0;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ static uint8_t hyundai_get_counter(CANPacket_t *to_push) {
|
|||
static uint32_t hyundai_get_checksum(CANPacket_t *to_push) {
|
||||
int addr = GET_ADDR(to_push);
|
||||
|
||||
uint8_t chksum;
|
||||
uint8_t chksum = 0;
|
||||
if (addr == 0x260) {
|
||||
chksum = GET_BYTE(to_push, 7) & 0xFU;
|
||||
} else if (addr == 0x386) {
|
||||
|
@ -119,7 +118,6 @@ static uint32_t hyundai_get_checksum(CANPacket_t *to_push) {
|
|||
} else if (addr == 0x421) {
|
||||
chksum = GET_BYTE(to_push, 7) >> 4;
|
||||
} else {
|
||||
chksum = 0;
|
||||
}
|
||||
return chksum;
|
||||
}
|
||||
|
|
|
@ -101,11 +101,7 @@ uint32_t hyundai_common_canfd_compute_checksum(CANPacket_t *to_push) {
|
|||
crc = (crc << 8U) ^ hyundai_canfd_crc_lut[(crc >> 8U) ^ ((address >> 0U) & 0xFFU)];
|
||||
crc = (crc << 8U) ^ hyundai_canfd_crc_lut[(crc >> 8U) ^ ((address >> 8U) & 0xFFU)];
|
||||
|
||||
if (len == 8) {
|
||||
crc ^= 0x5f29U;
|
||||
} else if (len == 16) {
|
||||
crc ^= 0x041dU;
|
||||
} else if (len == 24) {
|
||||
if (len == 24) {
|
||||
crc ^= 0x819dU;
|
||||
} else if (len == 32) {
|
||||
crc ^= 0x9f5bU;
|
||||
|
|
|
@ -76,21 +76,15 @@ static uint32_t volkswagen_mqb_compute_crc(CANPacket_t *to_push) {
|
|||
}
|
||||
|
||||
uint8_t counter = volkswagen_mqb_get_counter(to_push);
|
||||
switch(addr) {
|
||||
case MSG_LH_EPS_03:
|
||||
crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter];
|
||||
break;
|
||||
case MSG_ESP_05:
|
||||
crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter];
|
||||
break;
|
||||
case MSG_TSK_06:
|
||||
crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter];
|
||||
break;
|
||||
case MSG_MOTOR_20:
|
||||
crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter];
|
||||
break;
|
||||
default: // Undefined CAN message, CRC check expected to fail
|
||||
break;
|
||||
if (addr == MSG_LH_EPS_03) {
|
||||
crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter];
|
||||
} else if (addr == MSG_ESP_05) {
|
||||
crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter];
|
||||
} else if (addr == MSG_TSK_06) {
|
||||
crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter];
|
||||
} else if (addr == MSG_MOTOR_20) {
|
||||
crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter];
|
||||
} else { // Undefined CAN message, CRC check expected to fail
|
||||
}
|
||||
crc = volkswagen_crc8_lut_8h2f[crc];
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ static uint8_t volkswagen_pq_get_counter(CANPacket_t *to_push) {
|
|||
} else if (addr == MSG_GRA_NEU) {
|
||||
counter = (uint8_t)(GET_BYTE(to_push, 2) & 0xF0U) >> 4;
|
||||
} else {
|
||||
counter = 0U;
|
||||
}
|
||||
|
||||
return counter;
|
||||
|
|
Loading…
Reference in New Issue