Fix Rivian ignition (#2163)

* fix rivian ignition

* rm

* fix

* wtf copilot
This commit is contained in:
Shane Smiskol
2025-02-24 12:44:30 -08:00
committed by GitHub
parent e08311bb4d
commit 9a68935fb1

View File

@@ -182,10 +182,17 @@ void ignition_can_hook(CANPacket_t *to_push) {
// Tesla Model 3/Y exception
if ((addr == 0x221) && (len == 8)) {
// VCFRONT_LVPowerState->VCFRONT_vehiclePowerState
int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U;
ignition_can = power_state == 0x3; // VEHICLE_POWER_STATE_DRIVE=3
ignition_can_cnt = 0U;
// 0x221 overlaps with Rivian which has random data on byte 0
static int prev_counter = -1;
int counter = GET_BYTE(to_push, 6) >> 4;
if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) {
// VCFRONT_LVPowerState->VCFRONT_vehiclePowerState
int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U;
ignition_can = power_state == 0x3; // VEHICLE_POWER_STATE_DRIVE=3
ignition_can_cnt = 0U;
}
prev_counter = counter;
}
// Mazda exception