From 1847dc78e3f1ea7d57ccc81211d84f42859811d2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 29 Apr 2024 19:40:22 -0500 Subject: [PATCH] wip --- panda/board/safety/safety_hyundai.h | 11 ++++++++--- panda/board/safety/safety_hyundai_canfd.h | 1 + selfdrive/car/hyundai/carstate.py | 10 +++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/panda/board/safety/safety_hyundai.h b/panda/board/safety/safety_hyundai.h index a849a87..49565b9 100644 --- a/panda/board/safety/safety_hyundai.h +++ b/panda/board/safety/safety_hyundai.h @@ -283,9 +283,14 @@ static bool hyundai_tx_hook(const CANPacket_t *to_send) { if ((addr == 0x4F1) && !hyundai_longitudinal) { int button = GET_BYTE(to_send, 0) & 0x7U; - bool allowed_resume = (button == 1) && controls_allowed; - bool allowed_cancel = (button == 4) && cruise_engaged_prev; - if (!(allowed_resume || allowed_cancel)) { + // bool allowed_resume = (button == 1) && controls_allowed; + // bool allowed_cancel = (button == 4) && cruise_engaged_prev; + // if (!(allowed_resume || allowed_cancel)) { + // tx = false; + // } + + // CLEARPILOT - Allow buttons 1 (accel), 2 (decel), 4 (pause/resume) + if (!(button == 1 || button == 2 || button == 3)) { tx = false; } } diff --git a/panda/board/safety/safety_hyundai_canfd.h b/panda/board/safety/safety_hyundai_canfd.h index fb6ccf5..5e9e140 100644 --- a/panda/board/safety/safety_hyundai_canfd.h +++ b/panda/board/safety/safety_hyundai_canfd.h @@ -243,6 +243,7 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) { } // cruise buttons check + // CLEARPILOT - TODO - Allow buttons 1 (accel), 2 (decel), 4 (pause/resume) if (addr == 0x1cf) { int button = GET_BYTE(to_send, 2) & 0x7U; bool is_cancel = (button == HYUNDAI_BTN_CANCEL); diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 708bced..0e892b6 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -278,7 +278,15 @@ class CarState(CarStateBase): self.distance_button = self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0 self.lkas_previously_enabled = self.lkas_enabled - self.lkas_enabled = cp.vl[self.cruise_btns_msg_canfd]["LKAS_BTN"] + + # CLEARPILOT fix + lkas_enabled = False + try: + lkas_enabled = cp.vl[self.cruise_btns_msg_canfd]["LKAS_BTN"] + except: + nothing = 0 + + self.lkas_enabled = lkas_enabled self.params_memory.put_float("CarSpeedLimit", self.calculate_speed_limit(cp, cp_cam) * speed_factor)