From bf1ef875eecf60ded11caa0fbe5dcef6642ce22e Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Sun, 8 Sep 2019 14:02:27 -0700 Subject: [PATCH] Add GM passive safety mode (#266) --- VERSION | 2 +- board/safety.h | 3 +++ board/safety/safety_gm_passive.h | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 board/safety/safety_gm_passive.h diff --git a/VERSION b/VERSION index ef6abda..ff1560e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.4.6 \ No newline at end of file +v1.4.7 diff --git a/board/safety.h b/board/safety.h index 6b2b5a0..7cc9f44 100644 --- a/board/safety.h +++ b/board/safety.h @@ -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" @@ -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 @@ -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}, diff --git a/board/safety/safety_gm_passive.h b/board/safety/safety_gm_passive.h new file mode 100644 index 0000000..1f81970 --- /dev/null +++ b/board/safety/safety_gm_passive.h @@ -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, +};