From b2a7de49e45916dc049cb9643fa2024d824de002 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 4 May 2024 02:57:01 -0500 Subject: [PATCH] wip --- panda/board/safety/safety_hyundai_canfd.h | 37 ++------------------ panda/board/safety/safty_hyundai_canfd.h.wip | 0 2 files changed, 2 insertions(+), 35 deletions(-) create mode 100644 panda/board/safety/safty_hyundai_canfd.h.wip diff --git a/panda/board/safety/safety_hyundai_canfd.h b/panda/board/safety/safety_hyundai_canfd.h index e2cc658..f847a8d 100644 --- a/panda/board/safety/safety_hyundai_canfd.h +++ b/panda/board/safety/safety_hyundai_canfd.h @@ -21,14 +21,12 @@ const SteeringLimits HYUNDAI_CANFD_STEERING_LIMITS = { const CanMsg HYUNDAI_CANFD_HDA2_TX_MSGS[] = { {0x50, 0, 16}, // LKAS {0x1CF, 1, 8}, // CRUISE_BUTTON - {426, 1, 16}, // CRUISE_BUTTON_ALT (clearpilot) {0x2A4, 0, 24}, // CAM_0x2A4 }; const CanMsg HYUNDAI_CANFD_HDA2_ALT_STEERING_TX_MSGS[] = { {0x110, 0, 32}, // LKAS_ALT {0x1CF, 1, 8}, // CRUISE_BUTTON - {426, 1, 16}, // CRUISE_BUTTONS_ALT (clearpilot) {0x362, 0, 32}, // CAM_0x362 }; @@ -46,7 +44,6 @@ const CanMsg HYUNDAI_CANFD_HDA2_LONG_TX_MSGS[] = { {0x200, 1, 8}, // ADRV_0x200 {0x345, 1, 8}, // ADRV_0x345 {0x1DA, 1, 32}, // ADRV_0x1da - }; const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = { @@ -246,47 +243,17 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) { } // cruise buttons check - // CLEARPILOT - 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); bool is_resume = (button == HYUNDAI_BTN_RESUME); - bool is_set_decel = (button == HYUNDAI_BTN_SET); - - // 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_set_decel && controls_allowed); + bool allowed = (is_cancel && cruise_engaged_prev) || (is_resume && controls_allowed); if (!allowed) { tx = false; } } - // CRUISE_BUTTONS_ALT - // if (addr == 426) { - // // this gets bit 16 we want bit 36 - // int button = GET_BYTE(to_send, 2) & 0x7byteU; - // bool is_cancel = (button == HYUNDAI_BTN_CANCEL); - // bool is_resume = (button == HYUNDAI_BTN_RESUME); - // bool is_set_decel = (button == HYUNDAI_BTN_SET); - // // Canfd doc says there is a value 4 button allowed for canfd too, which one is it? - // // 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_set_decel && controls_allowed); - - // if (!allowed) { - // tx = false; - // } - // } - - // CLEARPILOT - Allow DRIVE_MODE2 - // if (addr == 1144) { - // } - // UDS: only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address if ((addr == 0x730) && hyundai_canfd_hda2) { if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) { @@ -390,4 +357,4 @@ const safety_hooks hyundai_canfd_hooks = { .get_counter = hyundai_canfd_get_counter, .get_checksum = hyundai_canfd_get_checksum, .compute_checksum = hyundai_common_canfd_compute_checksum, -}; +}; \ No newline at end of file diff --git a/panda/board/safety/safty_hyundai_canfd.h.wip b/panda/board/safety/safty_hyundai_canfd.h.wip new file mode 100644 index 0000000..e69de29