11#include "board/drivers/drivers.h"
2+ #include "opendbc/safety/ignition.h"
23
34uint32_t safety_tx_blocked = 0 ;
45uint32_t safety_rx_invalid = 0 ;
@@ -7,10 +8,6 @@ uint32_t rx_buffer_overflow = 0;
78
89can_health_t can_health [PANDA_CAN_CNT ] = {{0 }, {0 }, {0 }};
910
10- // Ignition detected from CAN meessages
11- bool ignition_can = false;
12- uint32_t ignition_can_cnt = 0U ;
13-
1411bool can_silent = true;
1512bool can_loopback = false;
1613
@@ -155,61 +152,6 @@ void can_set_forwarding(uint8_t from, uint8_t to) {
155152}
156153#endif
157154
158- void ignition_can_hook (CANPacket_t * msg ) {
159- if (msg -> bus == 0U ) {
160- int len = GET_LEN (msg );
161-
162- // GM exception
163- if ((msg -> addr == 0x1F1U ) && (len == 8 )) {
164- // SystemPowerMode (2=Run, 3=Crank Request)
165- ignition_can = (msg -> data [0 ] & 0x2U ) != 0U ;
166- ignition_can_cnt = 0U ;
167- }
168-
169- // Rivian R1S/T GEN1 exception
170- if ((msg -> addr == 0x152U ) && (len == 8 )) {
171- // 0x152 overlaps with Subaru pre-global which has this bit as the high beam
172- int counter = msg -> data [1 ] & 0xFU ; // max is only 14
173-
174- static int prev_counter_rivian = -1 ;
175- if ((counter == ((prev_counter_rivian + 1 ) % 15 )) && (prev_counter_rivian != -1 )) {
176- // VDM_OutputSignals->VDM_EpasPowerMode
177- ignition_can = ((msg -> data [7 ] >> 4U ) & 0x3U ) == 1U ; // VDM_EpasPowerMode_Drive_On=1
178- ignition_can_cnt = 0U ;
179- }
180- prev_counter_rivian = counter ;
181- }
182-
183- // Tesla Model 3/Y exception
184- if ((msg -> addr == 0x221U ) && (len == 8 )) {
185- // 0x221 overlaps with Rivian which has random data on byte 0
186- int counter = msg -> data [6 ] >> 4 ;
187-
188- static int prev_counter_tesla = -1 ;
189- if ((counter == ((prev_counter_tesla + 1 ) % 16 )) && (prev_counter_tesla != -1 )) {
190- // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState
191- int power_state = (msg -> data [0 ] >> 5U ) & 0x3U ;
192- ignition_can = power_state == 0x3 ; // VEHICLE_POWER_STATE_DRIVE=3
193- ignition_can_cnt = 0U ;
194- }
195- prev_counter_tesla = counter ;
196- }
197-
198- // Mazda exception
199- if ((msg -> addr == 0x9EU ) && (len == 8 )) {
200- ignition_can = (msg -> data [0 ] >> 5 ) == 0x6U ;
201- ignition_can_cnt = 0U ;
202- }
203- }
204-
205- // TODO: this is too loose, Teslas have 0x222
206- // body v2 exception
207- // if (((msg->bus == 0U) || (msg->bus == 2U)) && (msg->addr == 0x222U)) {
208- // ignition_can = true;
209- // ignition_can_cnt = 0U;
210- // }
211- }
212-
213155bool can_tx_check_min_slots_free (uint32_t min ) {
214156 return
215157 (can_slots_empty (& can_tx1_q ) >= min ) &&
0 commit comments