2
2
3
3
#include "safety_declarations.h"
4
4
5
+ // TODO: do checksum and counter checks. Add correct timestep, 0.1s for now.
6
+ #define GM_COMMON_RX_CHECKS \
7
+ {.msg = {{0x184, 0, 8, .ignore_checksum = true, .ignore_counter = true, .frequency = 10U}, { 0 }, { 0 }}}, \
8
+ {.msg = {{0x34A, 0, 5, .ignore_checksum = true, .ignore_counter = true, .frequency = 10U}, { 0 }, { 0 }}}, \
9
+ {.msg = {{0x1E1, 0, 7, .ignore_checksum = true, .ignore_counter = true, .frequency = 10U}, { 0 }, { 0 }}}, \
10
+ {.msg = {{0xBE, 0, 6, .ignore_checksum = true, .ignore_counter = true, .frequency = 10U}, /* Volt, Silverado, Acadia Denali */ \
11
+ {0xBE , 0 , 7 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, /* Bolt EUV */ \
12
+ {0xBE , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }}}, /* Escalade */ \
13
+ {.msg = {{0x1C4 , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}}, \
14
+ {.msg = {{0xC9 , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}}, \
15
+
5
16
static const LongitudinalLimits * gm_long_limits ;
6
17
7
18
enum {
@@ -18,13 +29,12 @@ typedef enum {
18
29
static GmHardware gm_hw = GM_ASCM ;
19
30
static bool gm_cam_long = false;
20
31
static bool gm_pcm_cruise = false;
32
+ static bool gm_ev = false;
21
33
22
34
static void gm_rx_hook (const CANPacket_t * to_push ) {
23
35
24
36
const int GM_STANDSTILL_THRSLD = 10 ; // 0.311kph
25
37
26
-
27
-
28
38
if (GET_BUS (to_push ) == 0U ) {
29
39
int addr = GET_ADDR (to_push );
30
40
@@ -178,6 +188,7 @@ static bool gm_fwd_hook(int bus_num, int addr) {
178
188
179
189
static safety_config gm_init (uint16_t param ) {
180
190
const uint16_t GM_PARAM_HW_CAM = 1 ;
191
+ const uint16_t GM_PARAM_EV = 4 ;
181
192
182
193
static const LongitudinalLimits GM_ASCM_LONG_LIMITS = {
183
194
.max_gas = 3072 ,
@@ -202,22 +213,20 @@ static safety_config gm_init(uint16_t param) {
202
213
{0x184 , 2 , 8 , false}}; // camera bus
203
214
204
215
205
- // TODO: do checksum and counter checks. Add correct timestep, 0.1s for now.
206
216
static RxCheck gm_rx_checks [] = {
207
- {.msg = {{0x184 , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}},
208
- {.msg = {{0x34A , 0 , 5 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}},
209
- {.msg = {{0x1E1 , 0 , 7 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}},
210
- {.msg = {{0xBE , 0 , 6 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, // Volt, Silverado, Acadia Denali
211
- {0xBE , 0 , 7 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, // Bolt EUV
212
- {0xBE , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }}}, // Escalade
213
- {.msg = {{0x1C4 , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}},
214
- {.msg = {{0xC9 , 0 , 8 , .ignore_checksum = true, .ignore_counter = true, .frequency = 10U }, { 0 }, { 0 }}},
217
+ GM_COMMON_RX_CHECKS
218
+ };
219
+
220
+ static RxCheck gm_ev_rx_checks [] = {
221
+ GM_COMMON_RX_CHECKS
222
+ {.msg = {{0xBD , 0 , 7 , .ignore_checksum = true, .ignore_counter = true, .frequency = 40U }, { 0 }, { 0 }}},
215
223
};
216
224
217
225
static const CanMsg GM_CAM_TX_MSGS [] = {{0x180 , 0 , 4 , true}, // pt bus
218
226
{0x1E1 , 2 , 7 , false}, {0x184 , 2 , 8 , false}}; // camera bus
219
227
220
228
gm_hw = GET_FLAG (param , GM_PARAM_HW_CAM ) ? GM_CAM : GM_ASCM ;
229
+ gm_ev = GET_FLAG (param , GM_PARAM_EV );
221
230
222
231
if (gm_hw == GM_ASCM ) {
223
232
gm_long_limits = & GM_ASCM_LONG_LIMITS ;
@@ -239,6 +248,9 @@ static safety_config gm_init(uint16_t param) {
239
248
// cppcheck-suppress knownConditionTrueFalse
240
249
ret = gm_cam_long ? BUILD_SAFETY_CFG (gm_rx_checks , GM_CAM_LONG_TX_MSGS ) : BUILD_SAFETY_CFG (gm_rx_checks , GM_CAM_TX_MSGS );
241
250
}
251
+ if (gm_ev ) {
252
+ SET_RX_CHECKS (gm_ev_rx_checks , ret );
253
+ }
242
254
return ret ;
243
255
}
244
256
0 commit comments