Skip to content

Commit

Permalink
Fix Rivian ignition (commaai#2163)
Browse files Browse the repository at this point in the history
* fix rivian ignition

* rm

* fix

* wtf copilot
  • Loading branch information
sshane authored Feb 24, 2025
1 parent e08311b commit 9a68935
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a68935

Please sign in to comment.