From 93863197dd3228649e286074f79a0174821a8a81 Mon Sep 17 00:00:00 2001 From: Igor Biletskyy Date: Thu, 31 Mar 2022 12:02:19 -0700 Subject: [PATCH] add safety mode for body (#901) * safety mode for body * move to 27 * dmm... * misra.. * add faw to safety list * missing safety modes in python lib * dmm * change address to 250 * add 0x1 addr for can flasehr * whitespace --- board/safety.h | 4 ++++ board/safety/safety_body.h | 25 +++++++++++++++++++++++++ python/__init__.py | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 board/safety/safety_body.h diff --git a/board/safety.h b/board/safety.h index 9b0b38762..768de4e24 100644 --- a/board/safety.h +++ b/board/safety.h @@ -15,6 +15,7 @@ #include "safety/safety_volkswagen_mqb.h" #include "safety/safety_volkswagen_pq.h" #include "safety/safety_elm327.h" +#include "safety/safety_body.h" // from cereal.car.CarParams.SafetyModel #define SAFETY_SILENT 0U @@ -40,6 +41,8 @@ #define SAFETY_HYUNDAI_LEGACY 23U #define SAFETY_HYUNDAI_COMMUNITY 24U #define SAFETY_STELLANTIS 25U +#define SAFETY_FAW 26U +#define SAFETY_BODY 27U uint16_t current_safety_mode = SAFETY_SILENT; int16_t current_safety_param = 0; @@ -251,6 +254,7 @@ const safety_hook_config safety_hook_registry[] = { {SAFETY_NOOUTPUT, &nooutput_hooks}, {SAFETY_HYUNDAI_LEGACY, &hyundai_legacy_hooks}, {SAFETY_MAZDA, &mazda_hooks}, + {SAFETY_BODY, &body_hooks}, #ifdef ALLOW_DEBUG {SAFETY_TESLA, &tesla_hooks}, {SAFETY_SUBARU_LEGACY, &subaru_legacy_hooks}, diff --git a/board/safety/safety_body.h b/board/safety/safety_body.h new file mode 100644 index 000000000..6a1d057e9 --- /dev/null +++ b/board/safety/safety_body.h @@ -0,0 +1,25 @@ +static int body_tx_hook(CANPacket_t *to_send) { + + int tx = 0; + int addr = GET_ADDR(to_send); + + // CAN flasher + if (addr == 0x1) { + tx = 1; + } + + if (addr == 0x250) { + tx = 1; + } + + // 1 allows the message through + return tx; +} + +const safety_hooks body_hooks = { + .init = nooutput_init, + .rx = default_rx_hook, + .tx = body_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = default_fwd_hook, +}; diff --git a/python/__init__.py b/python/__init__.py index 14e76515b..fb1d24a8a 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -138,6 +138,10 @@ class Panda(object): SAFETY_VOLKSWAGEN_PQ = 21 SAFETY_SUBARU_LEGACY = 22 SAFETY_HYUNDAI_LEGACY = 23 + SAFETY_HYUNDAI_COMMUNITY = 24 + SAFETY_STELLANTIS = 25 + SAFETY_FAW = 26 + SAFETY_BODY = 27 SERIAL_DEBUG = 0 SERIAL_ESP = 1