Skip to content

Commit bf1ef87

Browse files
vntarasovrbiasini
authored andcommitted
Add GM passive safety mode (#266)
1 parent c131fff commit bf1ef87

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.4.6
1+
v1.4.7

board/safety.h

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "safety/safety_tesla.h"
99
#include "safety/safety_gm_ascm.h"
1010
#include "safety/safety_gm.h"
11+
#include "safety/safety_gm_passive.h"
1112
#include "safety/safety_ford.h"
1213
#include "safety/safety_cadillac.h"
1314
#include "safety/safety_hyundai.h"
@@ -55,6 +56,7 @@ typedef struct {
5556
#define SAFETY_TESLA 8U
5657
#define SAFETY_CHRYSLER 9U
5758
#define SAFETY_SUBARU 10U
59+
#define SAFETY_GM_PASSIVE 11U
5860
#define SAFETY_GM_ASCM 0x1334U
5961
#define SAFETY_TOYOTA_IPAS 0x1335U
6062
#define SAFETY_ALLOUTPUT 0x1337U
@@ -72,6 +74,7 @@ const safety_hook_config safety_hook_registry[] = {
7274
{SAFETY_CHRYSLER, &chrysler_hooks},
7375
{SAFETY_SUBARU, &subaru_hooks},
7476
{SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks},
77+
{SAFETY_GM_PASSIVE, &gm_passive_hooks},
7578
{SAFETY_GM_ASCM, &gm_ascm_hooks},
7679
{SAFETY_TESLA, &tesla_hooks},
7780
{SAFETY_ALLOUTPUT, &alloutput_hooks},

board/safety/safety_gm_passive.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// All sending is disallowed.
2+
// The only difference from "no output" model
3+
// is using GM ignition hook.
4+
5+
static void gm_passive_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
6+
int bus_number = GET_BUS(to_push);
7+
int addr = GET_ADDR(to_push);
8+
9+
if ((addr == 0x1F1) && (bus_number == 0)) {
10+
bool ign = (GET_BYTE(to_push, 0) & 0x20) != 0;
11+
gm_ignition_started = ign;
12+
}
13+
}
14+
15+
const safety_hooks gm_passive_hooks = {
16+
.init = gm_init,
17+
.rx = gm_passive_rx_hook,
18+
.tx = nooutput_tx_hook,
19+
.tx_lin = nooutput_tx_lin_hook,
20+
.ignition = gm_ign_hook,
21+
.fwd = default_fwd_hook,
22+
};

0 commit comments

Comments
 (0)