Hyundai wheel speed counter is actually 4 bits spread over two signals

master
Adeeb Shihadeh 2020-05-17 22:40:51 -07:00
parent 0d581aa5f2
commit 0610ed1e25
2 changed files with 4 additions and 3 deletions

View File

@ -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) {

View File

@ -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)