diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index adfd1d4..a6166ab 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -12,7 +12,7 @@ const CanMsg HYUNDAI_TX_MSGS[] = {{832, 0, 8}, {1265, 0, 4}, {1157, 0, 4}}; AddrCheckStruct hyundai_rx_checks[] = { {.msg = {{608, 0, 8}}, .max_counter = 3U, .expected_timestep = 10000U}, {.msg = {{897, 0, 8}}, .max_counter = 255U, .expected_timestep = 10000U}, - {.msg = {{902, 0, 8}}, .max_counter = 3U, .expected_timestep = 10000U}, + {.msg = {{902, 0, 8}}, .max_counter = 15U, .expected_timestep = 10000U}, {.msg = {{916, 0, 8}}, .max_counter = 7U, .expected_timestep = 10000U}, {.msg = {{1057, 0, 8}}, .max_counter = 15U, .expected_timestep = 20000U}, }; @@ -27,7 +27,7 @@ static uint8_t hyundai_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { } else if (addr == 897) { cnt = GET_BYTE(to_push, 5); } else if (addr == 902) { - cnt = (GET_BYTE(to_push, 1) >> 6) & 0x3; + cnt = ((GET_BYTE(to_push, 3) >> 6) << 2) | (GET_BYTE(to_push, 1) >> 6); } else if (addr == 916) { cnt = (GET_BYTE(to_push, 1) >> 5) & 0x7; } else if (addr == 1057) { diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index dad07ed..88c1aa4 100644 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -53,7 +53,8 @@ class TestHyundaiSafety(common.PandaSafetyTest): def _speed_msg(self, speed): # panda safety doesn't scale, so undo the scaling values = {"WHL_SPD_%s"%s: speed*0.03125 for s in ["FL", "FR", "RL", "RR"]} - values["WHL_SPD_AliveCounter_LSB"] = self.cnt_speed % 4 + values["WHL_SPD_AliveCounter_LSB"] = (self.cnt_speed % 16) & 0x3 + values["WHL_SPD_AliveCounter_MSB"] = (self.cnt_speed % 16) >> 2 self.__class__.cnt_speed += 1 return self.packer.make_can_msg_panda("WHL_SPD11", 0, values)