@@ -166,6 +166,9 @@ void ignition_can_hook(CANPacket_t *to_push) {
166
166
int addr = GET_ADDR (to_push );
167
167
int len = GET_LEN (to_push );
168
168
169
+ // Check counter position on cars with overlap
170
+ static int prev_counter = -1 ;
171
+
169
172
// GM exception
170
173
if ((addr == 0x1F1 ) && (len == 8 )) {
171
174
// SystemPowerMode (2=Run, 3=Crank Request)
@@ -175,15 +178,20 @@ void ignition_can_hook(CANPacket_t *to_push) {
175
178
176
179
// Rivian R1S/T GEN1 exception
177
180
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 ;
181
190
}
182
191
183
192
// Tesla Model 3/Y exception
184
193
if ((addr == 0x221 ) && (len == 8 )) {
185
194
// 0x221 overlaps with Rivian which has random data on byte 0
186
- static int prev_counter = -1 ;
187
195
int counter = GET_BYTE (to_push , 6 ) >> 4 ;
188
196
189
197
if ((counter == ((prev_counter + 1 ) % 16 )) && (prev_counter != -1 )) {
0 commit comments