From 9068ec74f7f62924b49d7bb1a6126ebd7fe18d40 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 31 Oct 2026 11:58:04 -0500 Subject: [PATCH] Keep quiet-camera HKG discovery on normal wiring --- opendbc_repo/opendbc/car/hyundai/discovery.py | 7 ++- .../tests/test_quiet_canfd_discovery.py | 49 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 opendbc_repo/opendbc/car/hyundai/tests/test_quiet_canfd_discovery.py diff --git a/opendbc_repo/opendbc/car/hyundai/discovery.py b/opendbc_repo/opendbc/car/hyundai/discovery.py index 8111f2691a..753d23fc48 100644 --- a/opendbc_repo/opendbc/car/hyundai/discovery.py +++ b/opendbc_repo/opendbc/car/hyundai/discovery.py @@ -22,10 +22,15 @@ HDA2_NORMAL_BUS_LAYOUT = {(2, 0x50): 16, (2, 0x2A4): 24, (1, 0x35): 32, (1, 0xEA (1, 0xA0): 24, (1, 0x1A0): 32, (1, 0x1CF): 8, (1, 0x130): 16} +QUIET_CAMERA_NORMAL_BUS_LAYOUT = {(0, 0xEA): 24, (0, 0xA0): 24, (0, 0x1A0): 32, (0, 0x60): 32, + (0, 0x35): 32, (0, 0x1CF): 8, (0, 0x130): 16, + **{(1, address): 32 for address in range(0x210, 0x220)}} + + def _canfd_variant_layouts(): layouts = [] originals = (NORMAL_BUS_LAYOUT, HDA1_NORMAL_BUS_LAYOUT, HDA2_NORMAL_BUS_LAYOUT) - for base in originals: + for base in (*originals, QUIET_CAMERA_NORMAL_BUS_LAYOUT): bus = next(bus for bus, address in base if address == 0xEA) gears = ((0x130, 16), (0x40, 32), (0x70, 32)) if (bus, 0x130) in base else ((None, 0),) for accelerator, (buttons, length), (gear, gear_length) in product( diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_quiet_canfd_discovery.py b/opendbc_repo/opendbc/car/hyundai/tests/test_quiet_canfd_discovery.py new file mode 100644 index 0000000000..af1e433234 --- /dev/null +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_quiet_canfd_discovery.py @@ -0,0 +1,49 @@ +from unittest.mock import patch + +import pytest +from opendbc.car.can_definitions import CanData +from opendbc.car.hyundai.discovery import normal_bus_topology +from opendbc.car.car_helpers import fingerprint +from opendbc.car.vin import VIN_UNKNOWN + +# Source: d90ba2e1ecdbb770/0000000e--ed1fea4874, clean 7da9cea0f6. +LAYOUT = {(0, 0xEA): 24, (0, 0xA0): 24, (0, 0x1A0): 32, (0, 0x100): 32, + (0, 0x1AA): 16, (0, 0x40): 32, (0, 0x60): 32, + **{(1, address): 32 for address in range(0x210, 0x220)}} + + +def frames(): + return [CanData(address, bytes(length), bus) for (bus, address), length in LAYOUT.items()] + + +def test_recorded_tucson_with_quiet_camera_keeps_normal_query_wiring(): + assert normal_bus_topology(lambda **kw: [frames()]) + + +@pytest.mark.parametrize('index', range(len(LAYOUT))) +@pytest.mark.parametrize('defect', ['missing', 'length', 'bus', 'echo', 'contradiction']) +def test_quiet_camera_requires_complete_live_chassis_and_radar(index, defect): + source = frames() + frame = source.pop(index) + if defect in ('length', 'contradiction'): + source.append(CanData(frame.address, frame.dat[:-1], frame.src)) + if defect == 'contradiction': + source.append(frame) + elif defect != 'missing': + source.append(CanData(frame.address, frame.dat, frame.src + (128 if defect == 'echo' else 1))) + clock = iter([0., 0., .13]) + assert not normal_bus_topology(lambda **kw: [source], clock=lambda: next(clock)) + + +def test_actual_query_keeps_normal_bus_but_never_assigns_vehicle_identity(): + switches = [] + with patch('opendbc.car.car_helpers.get_vin', return_value=(-1, -1, VIN_UNKNOWN)), \ + patch('opendbc.car.car_helpers.get_fw_versions', return_value=[]) as query, \ + patch('opendbc.car.car_helpers.get_present_ecus', return_value=set()) as generic, \ + patch('opendbc.car.car_helpers.match_fw_to_car', return_value=(True, set())), \ + patch('opendbc.car.car_helpers.can_fingerprint', return_value=(None, {})): + actual = fingerprint(lambda wait_for_one=False: [frames()], lambda packets: None, switches.append, None) + assert actual[0] is None + assert switches and not any(switches) + assert query.call_args.kwargs == {'query_brand': 'hyundai', 'normal_bus_only': True} + generic.assert_not_called() diff --git a/prebuilt.json b/prebuilt.json index 2edd2132f4..9f767dc3f0 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "9d5fc77feca21c09342e7670e9fe0c2e0971ffd94fb5192b9c0f5b86ab284710", "schema_version": 1} +{"protected_inventory_sha256": "868381b1c309f270f146c1e4d6f8a3a1f02e06c46be1b2f9edaebb4a605dc9cf", "schema_version": 1}