diff --git a/board/safety.h b/board/safety.h index 2c6daddbd9..dc8962627d 100644 --- a/board/safety.h +++ b/board/safety.h @@ -247,8 +247,11 @@ bool addr_safety_check(CANPacket_t *to_push, } else { rx_checks->check[index].valid_quality_flag = true; } + return is_msg_valid(rx_checks->check, index); + } else { + // return invalid to safety modes for messages not in checks + return false; } - return is_msg_valid(rx_checks->check, index); } void generic_rx_checks(bool stock_ecu_detected) { diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index dec473b53d..1e55ec5835 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -224,7 +224,7 @@ static int hyundai_rx_hook(CANPacket_t *to_push) { } generic_rx_checks(stock_ecu_detected); } - return valid; + return true; } static int hyundai_tx_hook(CANPacket_t *to_send) { diff --git a/board/safety/safety_hyundai_canfd.h b/board/safety/safety_hyundai_canfd.h index 3ea7a486a5..1d6efec79e 100644 --- a/board/safety/safety_hyundai_canfd.h +++ b/board/safety/safety_hyundai_canfd.h @@ -53,6 +53,18 @@ const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = { {0x1E0, 0, 16}, // LFAHDA_CLUSTER }; +#define HYUNDAI_CANFD_EV_ADDR_CHECKS \ + /* ACCELERATOR: buses are swapped for HDA2 variants */ \ + {.msg = {{0x35, 1, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, \ + {0x35, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, { 0 }}}, \ + /* TCS buses are swapped for HDA2 variants */ \ + {.msg = {{0x175, 1, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, \ + {0x175, 0, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, { 0 }}}, \ + +#define HYUNDAI_CANFD_HYBRID_ADDR_CHECKS \ + /* ACCELERATOR_ALT: TODO: bus is always PT? no HDA hybrids? */ \ + {.msg = {{0x105, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, { 0 }, { 0 }}}, \ + AddrCheckStruct hyundai_canfd_addr_checks[] = { {.msg = {{0x35, 1, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, {0x35, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, @@ -253,7 +265,7 @@ static int hyundai_canfd_rx_hook(CANPacket_t *to_push) { } generic_rx_checks(stock_ecu_detected); - return valid; + return true; } static int hyundai_canfd_tx_hook(CANPacket_t *to_send) {