diff --git a/panda/board/drivers/can_common.h b/panda/board/drivers/can_common.h index eeaf87384e..fa69c69818 100644 --- a/panda/board/drivers/can_common.h +++ b/panda/board/drivers/can_common.h @@ -166,9 +166,6 @@ void ignition_can_hook(CANPacket_t *to_push) { int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); - // Check counter position on cars with overlap - static int prev_counter = -1; - // GM exception if ((addr == 0x1F1) && (len == 8)) { // SystemPowerMode (2=Run, 3=Crank Request) @@ -181,6 +178,7 @@ void ignition_can_hook(CANPacket_t *to_push) { // 0x152 overlaps with Subaru pre-global which has this bit as the high beam int counter = GET_BYTE(to_push, 1) & 0xFU; // max is only 14 + static int prev_counter = -1; if ((counter == ((prev_counter + 1) % 15)) && (prev_counter != -1)) { // VDM_OutputSignals->VDM_EpasPowerMode ignition_can = ((GET_BYTE(to_push, 7) >> 4U) & 0x3U) == 1U; // VDM_EpasPowerMode_Drive_On=1 @@ -194,6 +192,7 @@ void ignition_can_hook(CANPacket_t *to_push) { // 0x221 overlaps with Rivian which has random data on byte 0 int counter = GET_BYTE(to_push, 6) >> 4; + static int prev_counter = -1; if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) { // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U;