add safety param support

master
George Hotz 2018-01-25 23:57:04 -08:00
parent 65fb2b26cb
commit 4410a59d92
6 changed files with 11 additions and 11 deletions

View File

@ -274,7 +274,7 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
// and it's blocked over WiFi
// Allow ELM security mode to be set over wifi.
if (hardwired || setup->b.wValue.w == SAFETY_NOOUTPUT || setup->b.wValue.w == SAFETY_ELM327) {
safety_set_mode(setup->b.wValue.w);
safety_set_mode(setup->b.wValue.w, (int16_t)setup->b.wIndex.w);
switch (setup->b.wValue.w) {
case SAFETY_NOOUTPUT:
can_silent = ALL_CAN_SILENT;
@ -530,7 +530,7 @@ int main() {
usb_init();
// default to silent mode to prevent issues with Ford
safety_set_mode(SAFETY_NOOUTPUT);
safety_set_mode(SAFETY_NOOUTPUT, 0);
can_silent = ALL_CAN_SILENT;
can_init_all();

View File

@ -2,7 +2,7 @@ void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len);
typedef void (*safety_hook_init)();
typedef void (*safety_hook_init)(int16_t param);
typedef void (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push);
typedef int (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send);
typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len);
@ -60,11 +60,11 @@ const safety_hook_config safety_hook_registry[] = {
#define HOOK_CONFIG_COUNT (sizeof(safety_hook_registry)/sizeof(safety_hook_config))
int safety_set_mode(uint16_t mode) {
int safety_set_mode(uint16_t mode, int16_t param) {
for (int i = 0; i < HOOK_CONFIG_COUNT; i++) {
if (safety_hook_registry[i].id == mode) {
current_hooks = safety_hook_registry[i].hooks;
if (current_hooks->init) current_hooks->init();
if (current_hooks->init) current_hooks->init(param);
return 0;
}
}

View File

@ -2,7 +2,7 @@ void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {}
// *** no output safety mode ***
static void nooutput_init() {
static void nooutput_init(int16_t param) {
controls_allowed = 0;
}
@ -23,7 +23,7 @@ const safety_hooks nooutput_hooks = {
// *** all output safety mode ***
static void alloutput_init() {
static void alloutput_init(int16_t param) {
controls_allowed = 1;
}

View File

@ -27,7 +27,7 @@ static int elm327_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return true;
}
static void elm327_init() {
static void elm327_init(int16_t param) {
controls_allowed = 1;
}

View File

@ -115,7 +115,7 @@ static int honda_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return true;
}
static void honda_init() {
static void honda_init(int16_t param) {
controls_allowed = 0;
}

View File

@ -154,7 +154,7 @@ static int toyota_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return true;
}
static void toyota_init() {
static void toyota_init(int16_t param) {
controls_allowed = 0;
actuation_limits = 1;
}
@ -166,7 +166,7 @@ const safety_hooks toyota_hooks = {
.tx_lin = toyota_tx_lin_hook,
};
static void toyota_nolimits_init() {
static void toyota_nolimits_init(int16_t param) {
controls_allowed = 0;
actuation_limits = 0;
}