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
This commit is contained in:
Igor Biletskyy 2022-03-31 12:02:19 -07:00 committed by GitHub
parent 79145f9e5f
commit 93863197dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -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},

View File

@ -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,
};

View File

@ -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