Skip to content

Commit 0924df1

Browse files
authored
Rivian: fix ignition signal overlap (commaai#2165)
Fix Rivian ignition overlap
1 parent 9a68935 commit 0924df1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

board/drivers/can_common.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ void ignition_can_hook(CANPacket_t *to_push) {
166166
int addr = GET_ADDR(to_push);
167167
int len = GET_LEN(to_push);
168168

169+
// Check counter position on cars with overlap
170+
static int prev_counter = -1;
171+
169172
// GM exception
170173
if ((addr == 0x1F1) && (len == 8)) {
171174
// SystemPowerMode (2=Run, 3=Crank Request)
@@ -175,15 +178,20 @@ void ignition_can_hook(CANPacket_t *to_push) {
175178

176179
// Rivian R1S/T GEN1 exception
177180
if ((addr == 0x152) && (len == 8)) {
178-
// VDM_OutputSignals
179-
ignition_can = GET_BIT(to_push, 60U);
180-
ignition_can_cnt = 0U;
181+
// 0x152 overlaps with Subaru pre-global which has this bit as the high beam
182+
int counter = GET_BYTE(to_push, 1) & 0xFU; // max is only 14
183+
184+
if ((counter == ((prev_counter + 1) % 15)) && (prev_counter != -1)) {
185+
// VDM_OutputSignals
186+
ignition_can = GET_BIT(to_push, 60U);
187+
ignition_can_cnt = 0U;
188+
}
189+
prev_counter = counter;
181190
}
182191

183192
// Tesla Model 3/Y exception
184193
if ((addr == 0x221) && (len == 8)) {
185194
// 0x221 overlaps with Rivian which has random data on byte 0
186-
static int prev_counter = -1;
187195
int counter = GET_BYTE(to_push, 6) >> 4;
188196

189197
if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) {

0 commit comments

Comments
 (0)