From 79b791a26bd4644d04cc4fe8ae10b06c43c00938 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 10 Sep 2026 11:30:48 -0500 Subject: [PATCH] EV6 Hotfix --- .../opendbc/car/hyundai/carcontroller.py | 2 +- opendbc_repo/opendbc/car/hyundai/interface.py | 18 ++++++++++-------- .../opendbc/car/hyundai/tests/test_hyundai.py | 17 +++++++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index 4e22629680..e9aa5224ca 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -860,7 +860,7 @@ class CarController(CarControllerBase): lka_steering = self.CP.flags & HyundaiFlags.CANFD_LKA_STEERING longitudinal_active = bool(self.long_active_ecu and getattr(CC, "longActive", False)) - lfa_status_cars = (CAR.HYUNDAI_IONIQ_6, CAR.GENESIS_GV70_ELECTRIFIED_1ST_GEN) + lfa_status_cars = (CAR.HYUNDAI_IONIQ_6, CAR.GENESIS_GV70_ELECTRIFIED_1ST_GEN, CAR.KIA_EV6) lfa_longitudinal_active = self.CP.openpilotLongitudinalControl \ if self.CP.carFingerprint in lfa_status_cars else longitudinal_active lka_steering_long = lka_steering and lfa_longitudinal_active diff --git a/opendbc_repo/opendbc/car/hyundai/interface.py b/opendbc_repo/opendbc/car/hyundai/interface.py index 9b9d4e7290..4d95a15cee 100644 --- a/opendbc_repo/opendbc/car/hyundai/interface.py +++ b/opendbc_repo/opendbc/car/hyundai/interface.py @@ -27,6 +27,15 @@ from openpilot.starpilot.common.testing_grounds import testing_ground ButtonType = structs.CarState.ButtonEvent.Type Ecu = structs.CarParams.Ecu + +def get_communication_control_request(car_fingerprint): + if car_fingerprint in CANFD_RADAR_LIVE_LONGITUDINAL_CAR and car_fingerprint != CAR.KIA_EV6: + return bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, + uds.MESSAGE_TYPE.NORMAL]) + + return bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, 0x80 | uds.CONTROL_TYPE.DISABLE_RX_DISABLE_TX, + uds.MESSAGE_TYPE.NORMAL]) + # Cancel button can sometimes be ACC pause/resume button, main button can also enable on some cars ENABLE_BUTTONS = (ButtonType.accelCruise, ButtonType.decelCruise, ButtonType.cancel, ButtonType.mainCruise) @@ -353,14 +362,7 @@ class CarInterface(CarInterfaceBase): params = Params() if communication_control is None: - if CP.carFingerprint in CANFD_RADAR_LIVE_LONGITUDINAL_CAR: - # Don't use 0x80 suppress bit so we can read the ECU response. - # Use ENABLE_RX_DISABLE_TX (0x01) so the ECU can still receive from rear radars for BSM - # while blocking SCC TX. - communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) - else: - # 0x80 silences response for other cars (original behavior) - communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, 0x80 | uds.CONTROL_TYPE.DISABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) + communication_control = get_communication_control_request(CP.carFingerprint) ecu_log(f"=== init() called: opLong={CP.openpilotLongitudinalControl}, flags=0x{CP.flags:x}, safetyParam={CP.safetyConfigs[-1].safetyParam} ===") diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index e3a571adfe..666bba367f 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -4,7 +4,7 @@ from types import SimpleNamespace import pytest from opendbc.can import CANPacker, CANParser -from opendbc.car import Bus, ButtonType, gen_empty_fingerprint, structs +from opendbc.car import Bus, ButtonType, gen_empty_fingerprint, structs, uds from opendbc.car.structs import CarControl, CarParams from opendbc.car.fw_versions import build_fw_dict, match_fw_to_car from opendbc.car.hyundai.carcontroller import CarController, CANCEL_BUTTON_DELAY_FRAMES, Ioniq6LongitudinalTuningState, GenesisG90LongitudinalTuningState, \ @@ -24,7 +24,7 @@ from opendbc.car.hyundai.carcontroller import CarController, CANCEL_BUTTON_DELAY clear_ioniq_6_torque_when_request_inactive from opendbc.car.hyundai.carstate import CarState, decode_canfd_camera_lead, decode_ioniq_6_blindspot_radar_state, \ get_canfd_cruise_available -from opendbc.car.hyundai.interface import CarInterface, KIA_EV9_ACCEL_MAX +from opendbc.car.hyundai.interface import CarInterface, KIA_EV9_ACCEL_MAX, get_communication_control_request from opendbc.car.hyundai import hyundaican, hyundaicanfd from opendbc.car.hyundai.hyundaicanfd import CanBus, hkg_can_fd_checksum from opendbc.car.hyundai.radar_interface import MRREVO14F_RADAR_START_ADDR, MRR30_RADAR_START_ADDR, MRR35_RADAR_START_ADDR, \ @@ -129,6 +129,14 @@ def get_test_toggles() -> SimpleNamespace: class TestHyundaiFingerprint: + def test_ev6_uses_stock_hda2_communication_control_path(self): + stock_request = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, 0x83, uds.MESSAGE_TYPE.NORMAL]) + radar_keepalive_request = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, + uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) + + assert get_communication_control_request(CAR.KIA_EV6) == stock_request + assert get_communication_control_request(CAR.HYUNDAI_IONIQ_6) == radar_keepalive_request + def test_carnival_hev_low_speed_torque_rate_limits(self): CP = CarInterface.get_params(CAR.KIA_CARNIVAL_HEV_4TH_GEN, gen_empty_fingerprint(), [], False, False, False, None) @@ -2552,9 +2560,10 @@ class TestHyundaiFingerprint: if controller.packer.dbc.addr_to_msg[addr].name in ("LFA", "LKAS")] assert steering_names == [("LFA", can_bus.ECAN), ("LKAS", can_bus.ACAN)] - def test_ioniq_6_keeps_lfa_status_when_longitudinal_is_inactive(self): + @pytest.mark.parametrize("car", [CAR.HYUNDAI_IONIQ_6, CAR.KIA_EV6]) + def test_egmp_keeps_lfa_status_when_longitudinal_is_inactive(self, car): CP = CarParams.new_message() - CP.carFingerprint = CAR.HYUNDAI_IONIQ_6 + CP.carFingerprint = car CP.flags = int(HyundaiFlags.CANFD | HyundaiFlags.EV | HyundaiFlags.CANFD_LKA_STEERING) CP.openpilotLongitudinalControl = True