Skip to content

Commit

Permalink
Rivian: fix ignition signal overlap (commaai#2165)
Browse files Browse the repository at this point in the history
Fix Rivian ignition overlap
  • Loading branch information
sshane authored Feb 24, 2025
1 parent 9a68935 commit 0924df1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ 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)
Expand All @@ -175,15 +178,20 @@ void ignition_can_hook(CANPacket_t *to_push) {

// Rivian R1S/T GEN1 exception
if ((addr == 0x152) && (len == 8)) {
// VDM_OutputSignals
ignition_can = GET_BIT(to_push, 60U);
ignition_can_cnt = 0U;
// 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

if ((counter == ((prev_counter + 1) % 15)) && (prev_counter != -1)) {
// VDM_OutputSignals
ignition_can = GET_BIT(to_push, 60U);
ignition_can_cnt = 0U;
}
prev_counter = counter;
}

// Tesla Model 3/Y exception
if ((addr == 0x221) && (len == 8)) {
// 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)) {
Expand Down

0 comments on commit 0924df1

Please sign in to comment.