Honda safety: fixed bug and properly abstracted gas_interceptor_detected variable
parent
220cc8f4b5
commit
436b203e0b
|
@ -45,6 +45,7 @@ typedef struct {
|
|||
|
||||
// This can be set by the safety hooks.
|
||||
int controls_allowed = 0;
|
||||
int gas_interceptor_detected = 0;
|
||||
|
||||
// Include the actual safety policies.
|
||||
#include "safety/safety_defaults.h"
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
// brake rising edge
|
||||
// brake > 0mph
|
||||
|
||||
// these are set in the Honda safety hooks...this is the wrong place
|
||||
const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 328;
|
||||
int honda_gas_interceptor_detected = 0;
|
||||
int honda_brake_prev = 0;
|
||||
int honda_gas_prev = 0;
|
||||
int honda_gas_interceptor_prev = 0;
|
||||
|
@ -58,7 +56,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
|
|||
// exit controls on rising edge of gas press if interceptor (0x201 w/ len = 6)
|
||||
// length check because bosch hardware also uses this id (0x201 w/ len = 8)
|
||||
if ((to_push->RIR>>21) == 0x201 && (to_push->RDTR & 0xf) == 6) {
|
||||
honda_gas_interceptor_detected = 1;
|
||||
gas_interceptor_detected = 1;
|
||||
int gas_interceptor = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8);
|
||||
if ((gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD) &&
|
||||
(honda_gas_interceptor_prev <= HONDA_GAS_INTERCEPTOR_THRESHOLD)) {
|
||||
|
@ -68,7 +66,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
|
|||
}
|
||||
|
||||
// exit controls on rising edge of gas press if no interceptor
|
||||
if (!honda_gas_interceptor_detected) {
|
||||
if (!gas_interceptor_detected) {
|
||||
if ((to_push->RIR>>21) == 0x17C) {
|
||||
int gas = to_push->RDLR & 0xFF;
|
||||
if (gas && !(honda_gas_prev)) {
|
||||
|
|
|
@ -233,7 +233,7 @@ void init_tests_subaru(void){
|
|||
|
||||
void init_tests_honda(void){
|
||||
honda_ego_speed = 0;
|
||||
honda_gas_interceptor_detected = 0;
|
||||
gas_interceptor_detected = 0;
|
||||
honda_brake_prev = 0;
|
||||
honda_gas_prev = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue