From d79c10c0222ccf287f440d4a61807ea41e314140 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Tue, 2 Jul 2019 10:02:52 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20toyota=20d=5FallowGasOnOP?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=20panda=20=E6=AA=A2=E6=B8=AC=20gas/?= =?UTF-8?q?brake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- panda/board/safety/safety_toyota.h | 40 +++++++++++++++--------------- selfdrive/car/toyota/interface.py | 11 ++++---- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index d0fd90785..e552e3565 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -61,26 +61,26 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { toyota_cruise_engaged_last = cruise_engaged; } - // exit controls on rising edge of gas press if interceptor (0x201) - if ((to_push->RIR>>21) == 0x201) { - gas_interceptor_detected = 1; - int gas_interceptor = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8); - if ((gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && - (gas_interceptor_prev <= TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && - long_controls_allowed) { - controls_allowed = 0; - } - gas_interceptor_prev = gas_interceptor; - } - - // exit controls on rising edge of gas press - if ((to_push->RIR>>21) == 0x2C1) { - int gas = (to_push->RDHR >> 16) & 0xFF; - if ((gas > 0) && (toyota_gas_prev == 0) && !gas_interceptor_detected && long_controls_allowed) { - controls_allowed = 0; - } - toyota_gas_prev = gas; - } +// // exit controls on rising edge of gas press if interceptor (0x201) +// if ((to_push->RIR>>21) == 0x201) { +// gas_interceptor_detected = 1; +// int gas_interceptor = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8); +// if ((gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && +// (gas_interceptor_prev <= TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && +// long_controls_allowed) { +// controls_allowed = 0; +// } +// gas_interceptor_prev = gas_interceptor; +// } +// +// // exit controls on rising edge of gas press +// if ((to_push->RIR>>21) == 0x2C1) { +// int gas = (to_push->RDHR >> 16) & 0xFF; +// if ((gas > 0) && (toyota_gas_prev == 0) && !gas_interceptor_detected && long_controls_allowed) { +// controls_allowed = 0; +// } +// toyota_gas_prev = gas; +// } int bus = (to_push->RDTR >> 4) & 0xF; // msgs are only on bus 2 if panda is connected to frc diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 2789061d3..32817015c 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -374,15 +374,16 @@ class CarInterface(object): # while in standstill, send a user alert events.append(create_event('manualRestart', [ET.WARNING])) + # enable request in prius is simple, as we activate when Toyota is active (rising edge) + if ret.cruiseState.enabled and not self.cruise_enabled_prev: + events.append(create_event('pcmEnable', [ET.ENABLE])) + elif not ret.cruiseState.enabled: + events.append(create_event('pcmDisable', [ET.USER_DISABLE])) + if ret.gasPressed and not self.gas_pressed_prev and params.get("d_allowGasOnOP") == "0": events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) if ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001): - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # 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 \ - (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 and params.get("d_allowGasOnOP") == "0":