diff --git a/opendbc_repo/opendbc/car/toyota/dsu_bypass.py b/opendbc_repo/opendbc/car/toyota/dsu_bypass.py index 8bd79b6b9e..8e029f8537 100644 --- a/opendbc_repo/opendbc/car/toyota/dsu_bypass.py +++ b/opendbc_repo/opendbc/car/toyota/dsu_bypass.py @@ -30,9 +30,19 @@ AUTO_RESUME_CARS = frozenset((CAR.TOYOTA_HIGHLANDER, CAR.TOYOTA_PRIUS_V, CAR.TOY WORDS = frozenset(word | stock for word in PROFILES.values() for stock in (0, 0x200)) +def corolla_startup_mirror(candidate, fingerprint): + if candidate != CAR.TOYOTA_COROLLA: + return False + pt = fingerprint.get(0, {}) + return pt == fingerprint.get(2, {}) and all(pt.get(address) == length for address, length in + ((0xAA, 8), (0x262, 5), (0x1D3, 8), (0x343, 8), (0x4CB, 8))) + + def hardware_supported(candidate, fingerprint, car_fw): if candidate not in PROFILES or any(address in frames for frames in fingerprint.values() for address in (0x201, 0x2FF, 0x2AA)): return False + if corolla_startup_mirror(candidate, fingerprint): + return False camera = fingerprint.get(2, {}) if not any(camera.get(address) == 8 for address in (0x343, 0x4CB)) or any(camera.get(address, 8) != 8 for address in (0x343, 0x4CB)): return False diff --git a/opendbc_repo/opendbc/car/toyota/stock_aol.py b/opendbc_repo/opendbc/car/toyota/stock_aol.py index d5530c43fc..7b3bcbae9e 100644 --- a/opendbc_repo/opendbc/car/toyota/stock_aol.py +++ b/opendbc_repo/opendbc/car/toyota/stock_aol.py @@ -29,6 +29,9 @@ def hardware_supported(candidate, fingerprint): return False if 0x2FF in frames and not (candidate == CAR.TOYOTA_CAMRY and _cluster_radar_bus(candidate, bus, frames)): return False + from opendbc.car.toyota.dsu_bypass import corolla_startup_mirror + if corolla_startup_mirror(candidate, fingerprint): + return True camera = fingerprint.get(2, {}) if 0x4CB in camera: return False diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_corolla_startup_mirror.py b/opendbc_repo/opendbc/car/toyota/tests/test_corolla_startup_mirror.py new file mode 100644 index 0000000000..6eaa458b2f --- /dev/null +++ b/opendbc_repo/opendbc/car/toyota/tests/test_corolla_startup_mirror.py @@ -0,0 +1,21 @@ +import pytest + +from opendbc.car import gen_empty_fingerprint, structs +from opendbc.car.toyota.fingerprints import FW_VERSIONS +from opendbc.car.toyota.interface import CarInterface +from opendbc.car.toyota.values import CAR + + +@pytest.mark.parametrize('mirrored,expected', ((True, 0x5358), (False, 0x8958))) +def test_corolla_camera_relay_mirror_is_not_a_dsu_bypass(mirrored, expected): + car = CAR.TOYOTA_COROLLA + fp = gen_empty_fingerprint() + fp[0].update({0xAA: 8, 0x262: 5, 0x1D3: 8, 0x343: 8, 0x4CB: 8, 0x283: 7}) + fp[2].update(fp[0] if mirrored else {0x343: 8, 0x4CB: 8}) + fw = [structs.CarParams.CarFw(ecu=ecu, address=addr, subAddress=sub or 0, fwVersion=versions[0], brand='toyota', bus=0) + for (ecu, addr, sub), versions in FW_VERSIONS[car].items()] + + cp = CarInterface.get_params(car, fp, fw, False, True, False) + assert cp.safetyConfigs[0].safetyParam == expected + assert cp.pcmCruise + assert cp.openpilotLongitudinalControl is (not mirrored) diff --git a/prebuilt.json b/prebuilt.json index c7d0dca673..7691631aa1 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "f2840102ce177020b81b4855cf85f507c0b7ea184091ab4810da87c2f760e7b5", "schema_version": 1} +{"protected_inventory_sha256": "f7338c853e1b9158f22a9fd283879b8d54dbc038645dad0d456e4d971321ec36", "schema_version": 1}