hotfix: fix Rivian CAN ignition

devel-staging
Adeeb Shihadeh 1 week ago
parent a3f1354f27
commit b950992383
  1. 5
      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 addr = GET_ADDR(to_push);
int len = GET_LEN(to_push); int len = GET_LEN(to_push);
// Check counter position on cars with overlap
static int prev_counter = -1;
// GM exception // GM exception
if ((addr == 0x1F1) && (len == 8)) { if ((addr == 0x1F1) && (len == 8)) {
// SystemPowerMode (2=Run, 3=Crank Request) // 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 // 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 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)) { if ((counter == ((prev_counter + 1) % 15)) && (prev_counter != -1)) {
// VDM_OutputSignals->VDM_EpasPowerMode // VDM_OutputSignals->VDM_EpasPowerMode
ignition_can = ((GET_BYTE(to_push, 7) >> 4U) & 0x3U) == 1U; // VDM_EpasPowerMode_Drive_On=1 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 // 0x221 overlaps with Rivian which has random data on byte 0
int counter = GET_BYTE(to_push, 6) >> 4; int counter = GET_BYTE(to_push, 6) >> 4;
static int prev_counter = -1;
if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) { if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) {
// VCFRONT_LVPowerState->VCFRONT_vehiclePowerState // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState
int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U; int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U;

Loading…
Cancel
Save