Skip to content

Commit

Permalink
Add GM passive safety mode (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
vntarasov authored and rbiasini committed Sep 8, 2019
1 parent c131fff commit bf1ef87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.6
v1.4.7
3 changes: 3 additions & 0 deletions board/safety.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "safety/safety_tesla.h"
#include "safety/safety_gm_ascm.h"
#include "safety/safety_gm.h"
#include "safety/safety_gm_passive.h"
#include "safety/safety_ford.h"
#include "safety/safety_cadillac.h"
#include "safety/safety_hyundai.h"
Expand Down Expand Up @@ -55,6 +56,7 @@ typedef struct {
#define SAFETY_TESLA 8U
#define SAFETY_CHRYSLER 9U
#define SAFETY_SUBARU 10U
#define SAFETY_GM_PASSIVE 11U
#define SAFETY_GM_ASCM 0x1334U
#define SAFETY_TOYOTA_IPAS 0x1335U
#define SAFETY_ALLOUTPUT 0x1337U
Expand All @@ -72,6 +74,7 @@ const safety_hook_config safety_hook_registry[] = {
{SAFETY_CHRYSLER, &chrysler_hooks},
{SAFETY_SUBARU, &subaru_hooks},
{SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks},
{SAFETY_GM_PASSIVE, &gm_passive_hooks},
{SAFETY_GM_ASCM, &gm_ascm_hooks},
{SAFETY_TESLA, &tesla_hooks},
{SAFETY_ALLOUTPUT, &alloutput_hooks},
Expand Down
22 changes: 22 additions & 0 deletions board/safety/safety_gm_passive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// All sending is disallowed.
// The only difference from "no output" model
// is using GM ignition hook.

static void gm_passive_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
int bus_number = GET_BUS(to_push);
int addr = GET_ADDR(to_push);

if ((addr == 0x1F1) && (bus_number == 0)) {
bool ign = (GET_BYTE(to_push, 0) & 0x20) != 0;
gm_ignition_started = ign;
}
}

const safety_hooks gm_passive_hooks = {
.init = gm_init,
.rx = gm_passive_rx_hook,
.tx = nooutput_tx_hook,
.tx_lin = nooutput_tx_lin_hook,
.ignition = gm_ign_hook,
.fwd = default_fwd_hook,
};

0 comments on commit bf1ef87

Please sign in to comment.