From fe14c0506b042eb9c7342ce403e379514b9d74ff Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 4 May 2024 01:18:15 -0500 Subject: [PATCH] wip --- panda/board/safety/safety_hyundai_canfd.h | 6 ++++-- selfdrive/car/hyundai/carstate.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/panda/board/safety/safety_hyundai_canfd.h b/panda/board/safety/safety_hyundai_canfd.h index 3c0aacf..1861714 100644 --- a/panda/board/safety/safety_hyundai_canfd.h +++ b/panda/board/safety/safety_hyundai_canfd.h @@ -251,9 +251,11 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) { bool is_resume = (button == HYUNDAI_BTN_RESUME); bool is_set_decel = (button == 2); - bool allowed = (is_cancel && cruise_engaged_prev) + // bool allowed = (is_cancel && cruise_engaged_prev) + // Todo: allow is_cancel anytime speed > 0 on cruiseState + bool allowed = (is_cancel) || (is_resume && controls_allowed) - || (is_resume && is_set_decel); + || (is_set_decel && controls_allowed); if (!allowed) { tx = false; diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 723e633..b0bba6b 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -281,6 +281,7 @@ class CarState(CarStateBase): self.fix_main_enabled_check = False if ret.cruiseState.speed > 1 and self.main_enabled == False: self.fix_main_enabled_cancel_main = True + self.fix_main_enabled_executed = True self.buttons_counter = cp.vl[self.cruise_btns_msg_canfd]["COUNTER"] ret.accFaulted = cp.vl["TCS"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED