From 35a7e43045f106f59f03f051a14293ae1769fef7 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 27 May 2026 16:37:32 -0500 Subject: [PATCH] blocky block --- opendbc_repo/opendbc/safety/modes/hyundai_canfd.h | 13 +++++++++++++ .../opendbc/safety/tests/test_hyundai_canfd.py | 3 +++ 2 files changed, 16 insertions(+) diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h index 4d96fe939..eeadf2178 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h @@ -24,6 +24,9 @@ #define HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(e_can, longitudinal) \ {0x1A0, e_can, 32, .check_relay = (longitudinal)}, /* SCC_CONTROL */ \ +#define HYUNDAI_CANFD_MRR35_RADAR_TRACK_START 0x3A5 +#define HYUNDAI_CANFD_MRR35_RADAR_TRACK_END 0x3C4 + #define HYUNDAI_CANFD_BLINDSPOT_DASH_TX_MSGS(e_can) \ {0x1BA, e_can, 24, .check_relay = false}, /* BLINDSPOTS_REAR_CORNERS */ \ {0x1E5, e_can, 16, .check_relay = false}, /* BLINDSPOTS_FRONT_CORNER_1 */ \ @@ -81,6 +84,15 @@ static void hyundai_canfd_rx_all_hook(const CANPacket_t *msg) { SAFETY_UNUSED(msg); } +static bool hyundai_canfd_fwd_hook(int bus_num, int addr) { + const bool mrr35_radar_track = (addr >= HYUNDAI_CANFD_MRR35_RADAR_TRACK_START) && (addr <= HYUNDAI_CANFD_MRR35_RADAR_TRACK_END); + + // On LKA-steering long-control cars using live MRR35 radar tracks, openpilot parses + // the tracks directly from bus 0. Forwarding them to bus 2 creates a returned TX copy + // of every object frame on the logged CAN stream without adding planner data. + return hyundai_longitudinal && hyundai_canfd_lka_steering && (bus_num == 0) && mrr35_radar_track; +} + static void hyundai_canfd_rx_hook(const CANPacket_t *msg) { const unsigned pt_bus = hyundai_canfd_lka_steering ? 1U : 0U; @@ -485,4 +497,5 @@ 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, + .fwd = hyundai_canfd_fwd_hook, }; diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py index 75b7d7d8a..247936a0e 100755 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py @@ -26,6 +26,8 @@ ALL_GAS_EV_HYBRID_COMBOS = [ {"GAS_MSG": ("ACCELERATOR_ALT", "ACCELERATOR_PEDAL"), "SCC_BUS": 2, "SAFETY_PARAM": HyundaiSafetyFlags.HYBRID_GAS | HyundaiSafetyFlags.CAMERA_SCC}, ] +MRR35_RADAR_TRACK_ADDRS = list(range(0x3A5, 0x3C5)) + def _set_value(msg: bytearray, sig, ival: int) -> None: i = sig.lsb // 8 @@ -516,6 +518,7 @@ class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanf [0x1a0, 1], [0x1ea, 1], [0x200, 1], [0x345, 1], [0x1da, 1]] RELAY_MALFUNCTION_ADDRS = {0: (0x50, 0x2a4), 1: (0x1a0,)} # LKAS, CAM_0x2A4, SCC_CONTROL + FWD_BLACKLISTED_ADDRS = {0: MRR35_RADAR_TRACK_ADDRS, 2: [0x50, 0x2a4]} DISABLED_ECU_UDS_MSG = (0x730, 1) DISABLED_ECU_ACTUATION_MSG = (0x1a0, 1)