Rivian: fix ignition signal overlap (#2165)

Fix Rivian ignition overlap
This commit is contained in:
Shane Smiskol
2025-02-24 15:03:15 -08:00
committed by GitHub
parent 9a68935fb1
commit 0924df1e8e

View File

@@ -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)
@@ -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)) {