diff --git a/board/safety/safety_hyundai_canfd.h b/board/safety/safety_hyundai_canfd.h index c74467f49f..60fd34dceb 100644 --- a/board/safety/safety_hyundai_canfd.h +++ b/board/safety/safety_hyundai_canfd.h @@ -58,7 +58,7 @@ AddrCheckStruct hyundai_canfd_addr_checks[] = { {.msg = {{0xea, 1, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, {0xea, 0, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, { 0 }}}, {.msg = {{0x1a0, 1, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, - {0x1a0, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, { 0 }}}, + {0x1a0, 2, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, { 0 }}}, {.msg = {{0x1cf, 1, 8, .check_checksum = false, .max_counter = 0xfU, .expected_timestep = 20000U}, {0x1cf, 0, 8, .check_checksum = false, .max_counter = 0xfU, .expected_timestep = 20000U}, {0x1aa, 0, 16, .check_checksum = false, .max_counter = 0xffU, .expected_timestep = 20000U}}}, @@ -146,6 +146,7 @@ static int hyundai_canfd_rx_hook(CANPacket_t *to_push) { int addr = GET_ADDR(to_push); const int pt_bus = hyundai_canfd_hda2 ? 1 : 0; + const int scc_bus = hyundai_canfd_hda2 ? 1 : 2; if (valid && (bus == pt_bus)) { // driver torque @@ -170,12 +171,6 @@ static int hyundai_canfd_rx_hook(CANPacket_t *to_push) { hyundai_common_cruise_buttons_check(cruise_button, main_button); } - // cruise state - if ((addr == 0x1a0) && !hyundai_longitudinal) { - bool cruise_engaged = ((GET_BYTE(to_push, 8) >> 4) & 0x3U) != 0U; - hyundai_common_cruise_state_check(cruise_engaged); - } - // gas press, different for EV, hybrid, and ICE models if ((addr == 0x35) && hyundai_ev_gas_signal) { gas_pressed = GET_BYTE(to_push, 5) != 0U; @@ -199,6 +194,14 @@ static int hyundai_canfd_rx_hook(CANPacket_t *to_push) { } } + if (valid && (bus == scc_bus)) { + // cruise state + if ((addr == 0x1a0) && !hyundai_longitudinal) { + bool cruise_engaged = ((GET_BYTE(to_push, 8) >> 4) & 0x3U) != 0U; + hyundai_common_cruise_state_check(cruise_engaged); + } + } + const int steer_addr = hyundai_canfd_hda2 ? 0x50 : 0x12a; bool stock_ecu_detected = (addr == steer_addr) && (bus == 0); if (hyundai_longitudinal) { diff --git a/tests/safety/test.c b/tests/safety/test.c index b89bbc45ab..1644854581 100644 --- a/tests/safety/test.c +++ b/tests/safety/test.c @@ -83,7 +83,7 @@ bool addr_checks_valid() { const AddrCheckStruct addr = current_rx_checks->check[i]; bool valid = addr.msg_seen && !addr.lagging && addr.valid_checksum && (addr.wrong_counters < MAX_WRONG_COUNTERS); if (!valid) { - //printf("seen %d lagging %d valid checksum %d wrong counters %d\n", addr.msg_seen, addr.lagging, addr.valid_checksum, addr.wrong_counters); + printf("i %d seen %d lagging %d valid checksum %d wrong counters %d\n", i, addr.msg_seen, addr.lagging, addr.valid_checksum, addr.wrong_counters); return false; } } diff --git a/tests/safety/test_hyundai_canfd.py b/tests/safety/test_hyundai_canfd.py index ebdceaa40d..649e829d17 100755 --- a/tests/safety/test_hyundai_canfd.py +++ b/tests/safety/test_hyundai_canfd.py @@ -31,6 +31,7 @@ class TestHyundaiCanfdBase(HyundaiButtonBase, common.PandaSafetyTest, common.Dri MIN_VALID_STEERING_RT_INTERVAL = 810000 # a ~10% buffer, can send steer up to 110Hz PT_BUS = 0 + SCC_BUS = 2 STEER_BUS = 0 STEER_MSG = "" BUTTONS_TX_BUS = 1 @@ -64,7 +65,7 @@ def _user_gas_msg(self, gas): def _pcm_status_msg(self, enable): values = {"CRUISE_STATUS": 3 if enable else 0} - return self.packer.make_can_msg_panda("CRUISE_INFO", self.PT_BUS, values) + return self.packer.make_can_msg_panda("CRUISE_INFO", self.SCC_BUS, values) def _button_msg(self, buttons, main_button=0, bus=None): if bus is None: @@ -132,6 +133,7 @@ class TestHyundaiCanfdHDA2(TestHyundaiCanfdBase): FWD_BUS_LOOKUP = {0: 2, 2: 0} PT_BUS = 1 + SCC_BUS = 1 STEER_MSG = "LKAS" def setUp(self):