diff --git a/opendbc/car/hyundai/hyundaicanfd.py b/opendbc/car/hyundai/hyundaicanfd.py index 82ed0828b7..d3488ff531 100644 --- a/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc/car/hyundai/hyundaicanfd.py @@ -4,12 +4,11 @@ class CanBus(CanBusBase): - def __init__(self, CP, hda2=None, fingerprint=None) -> None: + def __init__(self, CP, fingerprint=None, hda2=None) -> None: super().__init__(CP, fingerprint) if hda2 is None: - assert CP is not None - hda2 = CP.flags & HyundaiFlags.CANFD_HDA2.value + hda2 = CP.flags & HyundaiFlags.CANFD_HDA2.value if CP is not None else False # On the CAN-FD platforms, the LKAS camera is on both A-CAN and E-CAN. HDA2 cars # have a different harness than the HDA1 and non-HDA variants in order to split diff --git a/opendbc/car/hyundai/interface.py b/opendbc/car/hyundai/interface.py index 49105b689e..5acc7a23cd 100644 --- a/opendbc/car/hyundai/interface.py +++ b/opendbc/car/hyundai/interface.py @@ -18,8 +18,9 @@ class CarInterface(CarInterfaceBase): def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs) -> structs.CarParams: ret.carName = "hyundai" - hda2 = Ecu.adas in [fw.ecu for fw in car_fw] - CAN = CanBus(None, hda2, fingerprint) + cam_can = CanBus(None, fingerprint).CAM + hda2 = 0x50 in fingerprint[cam_can] or 0x110 in fingerprint[cam_can] + CAN = CanBus(None, fingerprint, hda2) if candidate in CANFD_CAR: # Shared configuration for CAN-FD cars diff --git a/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc/car/hyundai/tests/test_hyundai.py index 9fc28827e1..2ac608ef3d 100644 --- a/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc/car/hyundai/tests/test_hyundai.py @@ -6,6 +6,7 @@ from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.hyundai.interface import CarInterface +from opendbc.car.hyundai.hyundaicanfd import CanBus from opendbc.car.hyundai.radar_interface import RADAR_START_ADDR from opendbc.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ HYBRID_CAR, EV_CAR, FW_QUERY_CONFIG, LEGACY_SAFETY_MODE_CAR, CANFD_FUZZY_WHITELIST, \ @@ -44,17 +45,20 @@ class TestHyundaiFingerprint: def test_feature_detection(self): # HDA2 - for has_adas in (True, False): - car_fw = [CarParams.CarFw(ecu=Ecu.adas if has_adas else Ecu.fwdCamera)] - CP = CarInterface.get_params(CAR.KIA_EV6, gen_empty_fingerprint(), car_fw, False, False) - assert bool(CP.flags & HyundaiFlags.CANFD_HDA2) == has_adas + for hda2 in (True, False): + fingerprint = gen_empty_fingerprint() + if hda2: + cam_can = CanBus(None, fingerprint).CAM + fingerprint[cam_can] = [0x50, 0x110] # HDA2 steering messages + CP = CarInterface.get_params(CAR.KIA_EV6, fingerprint, [], False, False) + assert bool(CP.flags & HyundaiFlags.CANFD_HDA2) == hda2 # radar available for radar in (True, False): fingerprint = gen_empty_fingerprint() if radar: fingerprint[1][RADAR_START_ADDR] = 8 - CP = CarInterface.get_params(CAR.HYUNDAI_SONATA, fingerprint, car_fw, False, False) + CP = CarInterface.get_params(CAR.HYUNDAI_SONATA, fingerprint, [], False, False) assert CP.radarUnavailable != radar def test_can_features(self):