diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index 660ec5fc1..8db509fbf 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -18,6 +18,7 @@ LongCtrlState = structs.CarControl.Actuators.LongControlState MAX_ANGLE = 85 MAX_ANGLE_FRAMES = 89 MAX_ANGLE_CONSECUTIVE_FRAMES = 2 +CANFD_BLINDSPOT_STATUS_STALE_NS = 200_000_000 def process_hud_alert(enabled, fingerprint, hud_control): @@ -138,7 +139,7 @@ class CarController(CarControllerBase): # *** CAN/CAN FD specific *** if self.CP.flags & HyundaiFlags.CANFD: - can_sends.extend(self.create_canfd_msgs(apply_steer_req, apply_torque, apply_angle, set_speed_in_units, accel, + can_sends.extend(self.create_canfd_msgs(now_nanos, apply_steer_req, apply_torque, apply_angle, set_speed_in_units, accel, stopping, hud_control, CS, CC)) else: can_sends.extend(self.create_can_msgs(apply_steer_req, apply_torque, torque_fault, set_speed_in_units, accel, @@ -203,7 +204,7 @@ class CarController(CarControllerBase): return can_sends - def create_canfd_msgs(self, apply_steer_req, apply_torque, apply_angle, set_speed_in_units, accel, stopping, hud_control, CS, CC): + def create_canfd_msgs(self, now_nanos, apply_steer_req, apply_torque, apply_angle, set_speed_in_units, accel, stopping, hud_control, CS, CC): can_sends = [] lka_steering = self.CP.flags & HyundaiFlags.CANFD_LKA_STEERING @@ -231,6 +232,13 @@ class CarController(CarControllerBase): can_sends.extend(hyundaicanfd.create_adrv_messages(self.packer, self.CAN, self.frame)) else: can_sends.extend(hyundaicanfd.create_fca_warning_light(self.packer, self.CAN, self.frame)) + if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6 and self.frame % 5 == 0: + rear_stale = now_nanos - CS.blindspots_rear_corners_ts > CANFD_BLINDSPOT_STATUS_STALE_NS + front_stale = now_nanos - CS.blindspots_front_corner_1_ts > CANFD_BLINDSPOT_STATUS_STALE_NS + if CS.blindspots_rear_corners_ts > 0 and CS.blindspots_front_corner_1_ts > 0 and rear_stale and front_stale: + can_sends.extend(hyundaicanfd.create_blindspot_status_messages(self.packer, self.CAN, + CS.blindspots_rear_corners, + CS.blindspots_front_corner_1)) if self.frame % 2 == 0: can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override, set_speed_in_units, hud_control)) diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 3bb406245..23e4cc909 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -78,6 +78,10 @@ class CarState(CarStateBase): self.buttons_counter = 0 self.cruise_info = {} + self.blindspots_rear_corners = {} + self.blindspots_front_corner_1 = {} + self.blindspots_rear_corners_ts = 0 + self.blindspots_front_corner_1_ts = 0 # On some cars, CLU15->CF_Clu_VehicleSpeed can oscillate faster than the dash updates. Sample at 5 Hz self.cluster_speed = 0 @@ -294,6 +298,12 @@ class CarState(CarStateBase): ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] != 0 ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0 + if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6: + self.blindspots_rear_corners = copy.copy(cp.vl["BLINDSPOTS_REAR_CORNERS"]) + self.blindspots_front_corner_1 = copy.copy(cp.vl["BLINDSPOTS_FRONT_CORNER_1"]) + self.blindspots_rear_corners_ts = cp.ts_nanos["BLINDSPOTS_REAR_CORNERS"]["CHECKSUM"] + self.blindspots_front_corner_1_ts = cp.ts_nanos["BLINDSPOTS_FRONT_CORNER_1"]["CHECKSUM"] + # cruise state # CAN FD cars enable on main button press, set available if no TCS faults preventing engagement ret.cruiseState.available = cp.vl["TCS"]["ACCEnable"] == 0 diff --git a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py index 250eccb6c..7d1d26153 100644 --- a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py @@ -196,6 +196,19 @@ def create_lfahda_cluster(packer, CAN, enabled): return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) +def create_blindspot_status_messages(packer, CAN, rear_values, front_corner_values): + # Reuse the last known-good payload but regenerate the rolling counter/checksum. + rear = {k: v for k, v in rear_values.items() if k not in ("CHECKSUM", "COUNTER")} + front = {k: v for k, v in front_corner_values.items() if k not in ("CHECKSUM", "COUNTER")} + if "NEW_SIGNAL_3" not in front: + front["NEW_SIGNAL_3"] = 1 + + return [ + packer.make_can_msg("BLINDSPOTS_REAR_CORNERS", CAN.ECAN, rear), + packer.make_can_msg("BLINDSPOTS_FRONT_CORNER_1", CAN.ECAN, front), + ] + + def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): jerk = 5 jn = jerk / 50 diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index ff2e6e2f5..41dcbac02 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -3,7 +3,7 @@ from types import SimpleNamespace import pytest -from opendbc.can import CANPacker +from opendbc.can import CANPacker, CANParser from opendbc.car import Bus, ButtonType, gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict, match_fw_to_car @@ -232,6 +232,52 @@ class TestHyundaiFingerprint: msgs = hyundaicanfd.create_steering_messages(packer, CP, CanBus(CP), True, True, 1.0, 12.3) assert [(addr, bus) for addr, _, bus in msgs] == [(0xCB, CanBus(CP).ECAN)] + def test_ioniq_6_blindspot_status_helper_regenerates_counter_checksum(self): + CP = CarParams.new_message() + CP.carFingerprint = CAR.HYUNDAI_IONIQ_6 + CP.flags = int(HyundaiFlags.CANFD | HyundaiFlags.CANFD_LKA_STEERING) + + packer = CANPacker(DBC[CP.carFingerprint][Bus.pt]) + can_bus = CanBus(CP) + parser = CANParser(DBC[CP.carFingerprint][Bus.pt], [("BLINDSPOTS_REAR_CORNERS", 0), ("BLINDSPOTS_FRONT_CORNER_1", 0)], can_bus.ECAN) + + rear = { + "CHECKSUM": 1111, + "COUNTER": 77, + "LEFT_BLOCKED": 0, + "LEFT_MB": 0, + "MORE_LEFT_PROB": 0, + "FL_INDICATOR": 0, + "FR_INDICATOR": 0, + "RIGHT_BLOCKED": 0, + "COLLISION_AVOIDANCE_ACTIVE": 0, + "NEW_SIGNAL_2": 0, + "FL_INDICATOR_ALT": 0, + "FR_INDICATOR_ALT": 0, + } + front = { + "CHECKSUM": 2222, + "COUNTER": 88, + "REVERSING": 0, + "NEW_SIGNAL_5": 0, + "NEW_SIGNAL_7": 0, + "NEW_SIGNAL_8": 0, + "NEW_SIGNAL_9": 0, + "NEW_SIGNAL_4": 0, + "NEW_SIGNAL_3": 1, + "NEW_SIGNAL_2": 0, + "NEW_SIGNAL_1": 0, + } + + msgs = hyundaicanfd.create_blindspot_status_messages(packer, can_bus, rear, front) + parser.update([(1, msgs)]) + + assert parser.can_valid + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["COUNTER"] == 0 + assert parser.vl["BLINDSPOTS_FRONT_CORNER_1"]["COUNTER"] == 0 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["LEFT_BLOCKED"] == 0 + assert parser.vl["BLINDSPOTS_FRONT_CORNER_1"]["NEW_SIGNAL_3"] == 1 + def test_sportage_angle_jerk_override_is_scoped(self): sportage = CarParams.new_message() sportage.carFingerprint = CAR.KIA_SPORTAGE_HEV_2026 diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h index 6fc16b974..ee50b824f 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h @@ -24,6 +24,10 @@ #define HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(e_can, longitudinal) \ {0x1A0, e_can, 32, .check_relay = (longitudinal)}, /* SCC_CONTROL */ \ +#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 */ \ + // *** Addresses checked in rx hook *** // EV, ICE, HYBRID: ACCELERATOR (0x35), ACCELERATOR_BRAKE_ALT (0x100), ACCELERATOR_ALT (0x105) #define HYUNDAI_CANFD_COMMON_RX_CHECKS(pt_bus) \ @@ -284,6 +288,7 @@ static safety_config hyundai_canfd_init(uint16_t param) { HYUNDAI_CANFD_LKA_STEERING_COMMON_TX_MSGS(0, 1) HYUNDAI_CANFD_LFA_STEERING_COMMON_TX_MSGS(1) HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(1, true) + HYUNDAI_CANFD_BLINDSPOT_DASH_TX_MSGS(1) {0x51, 0, 32, .check_relay = false}, // ADRV_0x51 {0x730, 1, 8, .check_relay = false}, // tester present for ADAS ECU disable {0x160, 1, 16, .check_relay = false}, // ADRV_0x160 @@ -304,6 +309,7 @@ static safety_config hyundai_canfd_init(uint16_t param) { HYUNDAI_CANFD_CRUISE_BUTTON_TX_MSGS(2) HYUNDAI_CANFD_LFA_STEERING_COMMON_TX_MSGS(0) HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(0, true) + HYUNDAI_CANFD_BLINDSPOT_DASH_TX_MSGS(0) {0x160, 0, 16, .check_relay = true}, // ADRV_0x160 {0x7D0, 0, 8, .check_relay = false}, // tester present for radar ECU disable }; @@ -343,6 +349,7 @@ static safety_config hyundai_canfd_init(uint16_t param) { static CanMsg hyundai_canfd_lfa_steering_camera_scc_tx_msgs[] = { HYUNDAI_CANFD_LFA_STEERING_CAMERA_SCC_TX_MSGS(true) + HYUNDAI_CANFD_BLINDSPOT_DASH_TX_MSGS(0) }; if (hyundai_canfd_alt_buttons) { diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py index 82511e8cb..9929bae0a 100755 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py @@ -451,7 +451,7 @@ class TestHyundaiCanfdLKASteeringAltEV(TestHyundaiCanfdBase): class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanfdLKASteeringEV): TX_MSGS = [[0x50, 0], [0x1CF, 1], [0x2A4, 0], [0x51, 0], [0x730, 1], [0x12a, 1], [0x160, 1], - [0x1e0, 1], [0x1a0, 1], [0x1ea, 1], [0x200, 1], [0x345, 1], [0x1da, 1]] + [0x1ba, 1], [0x1e0, 1], [0x1e5, 1], [0x1a0, 1], [0x1ea, 1], [0x200, 1], [0x345, 1], [0x1da, 1]] RELAY_MALFUNCTION_ADDRS = {0: (0x50, 0x2a4), 1: (0x1a0,)} # LKAS, CAM_0x2A4, SCC_CONTROL @@ -480,6 +480,7 @@ class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanf # Tests longitudinal for ICE, hybrid, EV cars with LFA steering class TestHyundaiCanfdLFASteeringLongBase(HyundaiLongitudinalBase, TestHyundaiCanfdLFASteeringBase): + TX_MSGS = [[0x12A, 0], [0x1A0, 1], [0x1CF, 0], [0x1E0, 0], [0x1BA, 0], [0x1E5, 0]] FWD_BLACKLISTED_ADDRS = {2: [0x12a, 0xcb, 0x1e0, 0x1a0, 0x160]} RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0xCB, 0x1E0, 0x1a0, 0x160)} # LFA, ADAS_CMD_35_10ms, LFAHDA_CLUSTER, SCC_CONTROL, ADRV_0x160 diff --git a/panda/board/obj/body_h7.bin.signed b/panda/board/obj/body_h7.bin.signed index ff84d39eb..f2a6d75f3 100644 Binary files a/panda/board/obj/body_h7.bin.signed and b/panda/board/obj/body_h7.bin.signed differ diff --git a/panda/board/obj/body_h7/bootstub.elf b/panda/board/obj/body_h7/bootstub.elf index d6cc8ee2b..4efe241b9 100755 Binary files a/panda/board/obj/body_h7/bootstub.elf and b/panda/board/obj/body_h7/bootstub.elf differ diff --git a/panda/board/obj/body_h7/main.bin b/panda/board/obj/body_h7/main.bin index bb433822c..9cab34a57 100755 Binary files a/panda/board/obj/body_h7/main.bin and b/panda/board/obj/body_h7/main.bin differ diff --git a/panda/board/obj/body_h7/main.elf b/panda/board/obj/body_h7/main.elf index 816eb624f..ee58fd9c1 100755 Binary files a/panda/board/obj/body_h7/main.elf and b/panda/board/obj/body_h7/main.elf differ diff --git a/panda/board/obj/bootstub.body_h7.bin b/panda/board/obj/bootstub.body_h7.bin index 1154c010f..780a23f3f 100755 Binary files a/panda/board/obj/bootstub.body_h7.bin and b/panda/board/obj/bootstub.body_h7.bin differ diff --git a/panda/board/obj/bootstub.panda.bin b/panda/board/obj/bootstub.panda.bin index 29a544740..2489b6456 100755 Binary files a/panda/board/obj/bootstub.panda.bin and b/panda/board/obj/bootstub.panda.bin differ diff --git a/panda/board/obj/bootstub.panda_h7.bin b/panda/board/obj/bootstub.panda_h7.bin index 9888e351c..0405b300a 100755 Binary files a/panda/board/obj/bootstub.panda_h7.bin and b/panda/board/obj/bootstub.panda_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_remote.bin b/panda/board/obj/bootstub.panda_h7_remote.bin index 9888e351c..0405b300a 100755 Binary files a/panda/board/obj/bootstub.panda_h7_remote.bin and b/panda/board/obj/bootstub.panda_h7_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_jungle_h7.bin b/panda/board/obj/bootstub.panda_jungle_h7.bin index 3bbfec881..0bdaf7bab 100755 Binary files a/panda/board/obj/bootstub.panda_jungle_h7.bin and b/panda/board/obj/bootstub.panda_jungle_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_remote.bin b/panda/board/obj/bootstub.panda_remote.bin index 29a544740..2489b6456 100755 Binary files a/panda/board/obj/bootstub.panda_remote.bin and b/panda/board/obj/bootstub.panda_remote.bin differ diff --git a/panda/board/obj/gitversion.h b/panda/board/obj/gitversion.h index 0ea3b6f47..520b3107f 100644 --- a/panda/board/obj/gitversion.h +++ b/panda/board/obj/gitversion.h @@ -1,2 +1,2 @@ extern const uint8_t gitversion[19]; -const uint8_t gitversion[19] = "DEV-031ad898-DEBUG"; +const uint8_t gitversion[19] = "DEV-9f1a9298-DEBUG"; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed index 570ed179b..53832ed9e 100644 Binary files a/panda/board/obj/panda.bin.signed and b/panda/board/obj/panda.bin.signed differ diff --git a/panda/board/obj/panda/bootstub.elf b/panda/board/obj/panda/bootstub.elf index e13775a5a..a4b70f8ac 100755 Binary files a/panda/board/obj/panda/bootstub.elf and b/panda/board/obj/panda/bootstub.elf differ diff --git a/panda/board/obj/panda/main.bin b/panda/board/obj/panda/main.bin index bd7813246..c9952de20 100755 Binary files a/panda/board/obj/panda/main.bin and b/panda/board/obj/panda/main.bin differ diff --git a/panda/board/obj/panda/main.elf b/panda/board/obj/panda/main.elf index 374dc4025..cb53d9574 100755 Binary files a/panda/board/obj/panda/main.elf and b/panda/board/obj/panda/main.elf differ diff --git a/panda/board/obj/panda_h7.bin.signed b/panda/board/obj/panda_h7.bin.signed index aa7574d8b..e2f6c71dd 100644 Binary files a/panda/board/obj/panda_h7.bin.signed and b/panda/board/obj/panda_h7.bin.signed differ diff --git a/panda/board/obj/panda_h7/bootstub.elf b/panda/board/obj/panda_h7/bootstub.elf index ae9287106..fa4c04749 100755 Binary files a/panda/board/obj/panda_h7/bootstub.elf and b/panda/board/obj/panda_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_h7/main.bin b/panda/board/obj/panda_h7/main.bin index 7c4b56df8..9d290ad26 100755 Binary files a/panda/board/obj/panda_h7/main.bin and b/panda/board/obj/panda_h7/main.bin differ diff --git a/panda/board/obj/panda_h7/main.elf b/panda/board/obj/panda_h7/main.elf index 91c602c54..03f8790dd 100755 Binary files a/panda/board/obj/panda_h7/main.elf and b/panda/board/obj/panda_h7/main.elf differ diff --git a/panda/board/obj/panda_h7_remote.bin.signed b/panda/board/obj/panda_h7_remote.bin.signed index 5ecd78842..8e55756c1 100644 Binary files a/panda/board/obj/panda_h7_remote.bin.signed and b/panda/board/obj/panda_h7_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote/bootstub.elf b/panda/board/obj/panda_h7_remote/bootstub.elf index e24a0962a..d852ade78 100755 Binary files a/panda/board/obj/panda_h7_remote/bootstub.elf and b/panda/board/obj/panda_h7_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_h7_remote/main.bin b/panda/board/obj/panda_h7_remote/main.bin index b2e4ee4a7..3bae2f537 100755 Binary files a/panda/board/obj/panda_h7_remote/main.bin and b/panda/board/obj/panda_h7_remote/main.bin differ diff --git a/panda/board/obj/panda_h7_remote/main.elf b/panda/board/obj/panda_h7_remote/main.elf index 5fdf57206..0040c8c82 100755 Binary files a/panda/board/obj/panda_h7_remote/main.elf and b/panda/board/obj/panda_h7_remote/main.elf differ diff --git a/panda/board/obj/panda_jungle_h7.bin.signed b/panda/board/obj/panda_jungle_h7.bin.signed index 07098d24a..f0450fbd0 100644 Binary files a/panda/board/obj/panda_jungle_h7.bin.signed and b/panda/board/obj/panda_jungle_h7.bin.signed differ diff --git a/panda/board/obj/panda_jungle_h7/bootstub.elf b/panda/board/obj/panda_jungle_h7/bootstub.elf index dff0c15c2..cb340d456 100755 Binary files a/panda/board/obj/panda_jungle_h7/bootstub.elf and b/panda/board/obj/panda_jungle_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_jungle_h7/main.bin b/panda/board/obj/panda_jungle_h7/main.bin index f7f90e62b..063d31fa3 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.bin and b/panda/board/obj/panda_jungle_h7/main.bin differ diff --git a/panda/board/obj/panda_jungle_h7/main.elf b/panda/board/obj/panda_jungle_h7/main.elf index 72cf9746b..64b5677e4 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.elf and b/panda/board/obj/panda_jungle_h7/main.elf differ diff --git a/panda/board/obj/panda_remote.bin.signed b/panda/board/obj/panda_remote.bin.signed index 18d7828d7..37c05ea78 100644 Binary files a/panda/board/obj/panda_remote.bin.signed and b/panda/board/obj/panda_remote.bin.signed differ diff --git a/panda/board/obj/panda_remote/bootstub.elf b/panda/board/obj/panda_remote/bootstub.elf index 93f27747d..be9be20c6 100755 Binary files a/panda/board/obj/panda_remote/bootstub.elf and b/panda/board/obj/panda_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_remote/main.bin b/panda/board/obj/panda_remote/main.bin index 66ab94a29..2702c9463 100755 Binary files a/panda/board/obj/panda_remote/main.bin and b/panda/board/obj/panda_remote/main.bin differ diff --git a/panda/board/obj/panda_remote/main.elf b/panda/board/obj/panda_remote/main.elf index ddfe24445..ed7bb7401 100755 Binary files a/panda/board/obj/panda_remote/main.elf and b/panda/board/obj/panda_remote/main.elf differ diff --git a/panda/board/obj/version b/panda/board/obj/version index 8225be37a..49889d2fa 100644 --- a/panda/board/obj/version +++ b/panda/board/obj/version @@ -1 +1 @@ -DEV-031ad898-DEBUG \ No newline at end of file +DEV-9f1a9298-DEBUG \ No newline at end of file