mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
Rivian: fix ignition signal overlap (#2165)
Fix Rivian ignition overlap
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user