From f7f899f05d63b81f0b5a537b196463cb15202a14 Mon Sep 17 00:00:00 2001 From: kegman <8837066+kegman@users.noreply.github.com> Date: Tue, 5 Nov 2019 22:57:47 -0500 Subject: [PATCH] Bosch Gas Press (#243) * Disabled gas press disengage for Bosch Honda * Disable gasPressed for Bosch in interface.py * Fix indent for interface.py gasPress Bosch disable * allow gas disengagement for CR-V (#237) * allow disengagement for CR-V (#238) already tested --- panda/board/safety/safety_honda.h | 8 +++++--- selfdrive/car/honda/interface.py | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/panda/board/safety/safety_honda.h b/panda/board/safety/safety_honda.h index 4399b07857668a..98216655cc1bee 100644 --- a/panda/board/safety/safety_honda.h +++ b/panda/board/safety/safety_honda.h @@ -18,6 +18,7 @@ bool honda_moving = false; bool honda_bosch_hardware = false; bool honda_alt_brake_msg = false; bool honda_fwd_brake = false; +bool bosch_ACC_allowed = false; static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { @@ -81,7 +82,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { if (!gas_interceptor_detected) { if (addr == 0x17C) { int gas = GET_BYTE(to_push, 0); - if (gas && !(honda_gas_prev) && long_controls_allowed) { + if (gas && !(honda_gas_prev) && long_controls_allowed && !(bosch_ACC_allowed)) { controls_allowed = 0; } honda_gas_prev = gas; @@ -146,7 +147,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True - int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || + int pedal_pressed = (!bosch_ACC_allowed && honda_gas_prev) || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || (honda_brake_pressed_prev && honda_moving); bool current_controls_allowed = controls_allowed && !(pedal_pressed); @@ -168,6 +169,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // STEER: safety check if ((addr == 0xE4) || (addr == 0x194)) { + bosch_ACC_allowed = honda_bosch_hardware; if (!current_controls_allowed) { bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1); if (steer_applied) { @@ -179,7 +181,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // GAS: safety check if (addr == 0x200) { if (!current_controls_allowed || !long_controls_allowed) { - if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { + if (!bosch_ACC_allowed && (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1))) { tx = 0; } } diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 14702a8913ad8e..53faa2e1637141 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -97,6 +97,11 @@ def __init__(self, CP, CarController): self.compute_gb = get_compute_gb_acura() else: self.compute_gb = compute_gb_honda + + if self.CS.CP.carFingerprint in HONDA_BOSCH: + self.bosch_honda = True + else: + self.bosch_honda = False @staticmethod def calc_accel_override(a_ego, a_target, v_ego, v_target): @@ -545,11 +550,11 @@ def update(self, c, can_strings): events.append(create_event('speedTooLow', [ET.NO_ENTRY])) # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ + if (ret.gasPressed and not self.gas_pressed_prev and not self.bosch_honda) or \ (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gasPressed: + if ret.gasPressed and not self.bosch_honda: events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) # it can happen that car cruise disables while comma system is enabled: need to