From abbc23fe1eaacf03c04cf7044272f4b0b948d162 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 24 Feb 2025 03:03:02 -0800 Subject: [PATCH 1/4] fix rivian ignition --- board/drivers/can_common.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index b7a157e442e..1d9cbe873a8 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -182,10 +182,19 @@ 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)) { + ignition_can_cnt += 1U; + // 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 From 4bbc0c4367343140ff6b86761c7838621d1cd91b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 24 Feb 2025 03:03:39 -0800 Subject: [PATCH 2/4] rm --- board/drivers/can_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 1d9cbe873a8..0bf7e014f82 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -193,7 +193,6 @@ void ignition_can_hook(CANPacket_t *to_push) { ignition_can = power_state == 0x3; // VEHICLE_POWER_STATE_DRIVE=3 ignition_can_cnt = 0U; } - prev_counter = counter; } From 66d252fe06a7ee3c08e787bd51a4b3c42223717f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 24 Feb 2025 03:04:39 -0800 Subject: [PATCH 3/4] fix --- board/drivers/can_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 0bf7e014f82..8739767b6be 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -186,7 +186,7 @@ void ignition_can_hook(CANPacket_t *to_push) { static int prev_counter = -1; int counter = GET_BYTE(to_push, 6) >> 4; - if ((counter == ((prev_counter + 1) % 16) && (prev_counter != -1)) { + if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) { ignition_can_cnt += 1U; // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U; From ea0f6cae63afbcda32b7fa684dcd7051e8187908 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 24 Feb 2025 03:06:58 -0800 Subject: [PATCH 4/4] wtf copilot --- board/drivers/can_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 8739767b6be..cefba6e8ca4 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -187,7 +187,6 @@ void ignition_can_hook(CANPacket_t *to_push) { int counter = GET_BYTE(to_push, 6) >> 4; if ((counter == ((prev_counter + 1) % 16)) && (prev_counter != -1)) { - ignition_can_cnt += 1U; // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState int power_state = (GET_BYTE(to_push, 0) >> 5U) & 0x3U; ignition_can = power_state == 0x3; // VEHICLE_POWER_STATE_DRIVE=3