mirror of https://github.com/commaai/panda.git
Fixed output_enabled led not turning off when mode changed to no output.
This commit is contained in:
parent
59592f599a
commit
27a8af1107
|
@ -10,6 +10,10 @@ int gas_interceptor_detected = 0;
|
|||
|
||||
void default__rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {}
|
||||
|
||||
void nooutput__init() {
|
||||
controls_allowed = false;
|
||||
}
|
||||
|
||||
int nooutput__tx_hook(CAN_FIFOMailBox_TypeDef *to_send, int hardwired) {
|
||||
return false;
|
||||
}
|
||||
|
@ -18,6 +22,10 @@ int nooutput__tx_lin_hook(int lin_num, uint8_t *data, int len, int hardwired) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void alloutput__init() {
|
||||
controls_allowed = true;
|
||||
}
|
||||
|
||||
int alloutput__tx_hook(CAN_FIFOMailBox_TypeDef *to_send, int hardwired) {
|
||||
return hardwired;
|
||||
}
|
||||
|
@ -27,12 +35,14 @@ int alloutput__tx_lin_hook(int lin_num, uint8_t *data, int len, int hardwired) {
|
|||
}
|
||||
|
||||
const safety_hooks nooutput_hooks = {
|
||||
.init = nooutput__init,
|
||||
.rx = default__rx_hook,
|
||||
.tx = alloutput__tx_hook,
|
||||
.tx_lin = alloutput__tx_lin_hook,
|
||||
};
|
||||
|
||||
const safety_hooks alloutput_hooks = {
|
||||
.init = alloutput__init,
|
||||
.rx = default__rx_hook,
|
||||
.tx = alloutput__tx_hook,
|
||||
.tx_lin = alloutput__tx_lin_hook,
|
||||
|
@ -77,7 +87,7 @@ int set_safety_mode(uint16_t mode){
|
|||
for(i = 0; i < HOOK_CONFIG_COUNT; i++){
|
||||
if(safety_hook_registry[i].id == mode){
|
||||
current_hooks = safety_hook_registry[i].hooks;
|
||||
controls_allowed = 1;
|
||||
current_hooks->init();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,13 @@ void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
|||
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send, int hardwired);
|
||||
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len, int hardwired);
|
||||
|
||||
typedef void (*safety_hook_init)();
|
||||
typedef void (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
typedef int (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send, int hardwired);
|
||||
typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len, int hardwired);
|
||||
|
||||
typedef struct {
|
||||
safety_hook_init init;
|
||||
rx_hook rx;
|
||||
tx_hook tx;
|
||||
tx_lin_hook tx_lin;
|
||||
|
|
|
@ -87,7 +87,12 @@ int honda__tx_lin_hook(int lin_num, uint8_t *data, int len, int hardwired) {
|
|||
return hardwired;
|
||||
}
|
||||
|
||||
void honda__init() {
|
||||
controls_allowed = true;
|
||||
}
|
||||
|
||||
const safety_hooks honda_hooks = {
|
||||
.init = honda__init,
|
||||
.rx = honda__rx_hook,
|
||||
.tx = honda__tx_hook,
|
||||
.tx_lin = honda__tx_lin_hook,
|
||||
|
|
Loading…
Reference in New Issue