diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index fad8629203..d0d5e88928 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -64,10 +64,10 @@ def fingerprint(logcan, sendcan, has_relay): # Vin query only reliably works thorugh OBDII bus = 1 addr, vin = get_vin(logcan, sendcan, bus) - _, car_fw = get_fw_versions(logcan, sendcan, bus) + fw_candidates, car_fw = get_fw_versions(logcan, sendcan, bus) else: vin = VIN_UNKNOWN - _, car_fw = set(), [] + fw_candidates, car_fw = set(), [] cloudlog.warning("VIN %s", vin) Params().put("CarVin", vin) @@ -113,6 +113,10 @@ def fingerprint(logcan, sendcan, has_relay): frame += 1 + # If FW query returns exactly 1 candidate, use it + if len(fw_candidates) == 1: + car_fingerprint = list(fw_candidates)[0] + cloudlog.warning("fingerprinted %s", car_fingerprint) return car_fingerprint, finger, vin, car_fw diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 1175c59784..e5bec9652f 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -6,6 +6,7 @@ from tqdm import tqdm from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery from selfdrive.swaglog import cloudlog from selfdrive.car.fingerprints import FW_VERSIONS +from selfdrive.car.toyota.values import CAR as TOYOTA import panda.python.uds as uds from cereal import car @@ -63,10 +64,12 @@ REQUESTS = [ ) ] + def chunks(l, n=128): for i in range(0, len(l), n): yield l[i:i + n] + def match_fw_to_car(fw_versions): candidates = FW_VERSIONS invalid = [] @@ -78,6 +81,14 @@ def match_fw_to_car(fw_versions): found_version = fw_versions.get(addr, None) + # TODO: RAV4, COROLLA esp sometimes doesn't show up + if ecu_type == Ecu.esp and candidate in [TOYOTA.RAV4, TOYOTA.COROLLA] and found_version is None: + continue + + # TODO: COROLLA_TSS2 engine can show on two different addresses + if ecu_type == Ecu.engine and candidate == TOYOTA.COROLLA_TSS2 and found_version is None: + continue + # Allow DSU not being present if ecu_type in [Ecu.unknown, Ecu.dsu] and found_version is None: continue diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index de62454f1e..3b9b6b0600 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -123,32 +123,249 @@ for c in FINGERPRINTS: # TODO: Figure out what is relevant FW_VERSIONS = { - CAR.CIVIC: { - (Ecu.unknown, 0x18da10f1, None): [b'37805-5AA-L660\x00\x00'], - (Ecu.unknown, 0x18da1ef1, None): [b'28101-5CG-A050\x00\x00'], - (Ecu.unknown, 0x18da28f1, None): [b'57114-TBA-A550\x00\x00'], - (Ecu.eps, 0x18da30f1, None): [b'39990-TBA-A030\x00\x00', b'39990-TBA,A030\x00\x00'], - (Ecu.unknown, 0x18da53f1, None): [b'77959-TBA-A030\x00\x00'], - (Ecu.unknown, 0x18da60f1, None): [b'78109-TBC-A310\x00\x00'], - (Ecu.unknown, 0x18dab0f1, None): [b'36161-TBC-A030\x00\x00'], - (Ecu.unknown, 0x18daeff1, None): [b'38897-TBA-A020\x00\x00'], - - }, CAR.ACCORD: { - (Ecu.unknown, 0x18da10f1, None): [b'37805-6B2-A650\x00\x00'], + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-6B2-A550\x00\x00', + b'37805-6B2-A650\x00\x00', + b'37805-6A0-A640\x00\x00', + ], (Ecu.unknown, 0x18da0bf1, None): [b'54008-TVC-A910\x00\x00'], (Ecu.unknown, 0x18da1ef1, None): [b'28102-6B8-A560\x00\x00'], (Ecu.unknown, 0x18da2bf1, None): [b'46114-TVA-A060\x00\x00'], (Ecu.unknown, 0x18da28f1, None): [b'57114-TVA-C050\x00\x00'], - (Ecu.eps, 0x18da30f1, None): [b'39990-TVA-A150\x00\x00'], + (Ecu.eps, 0x18da30f1, None): [b'39990-TVA-A150\x00\x00', b'39990-TVA-A160\x00\x00'], (Ecu.unknown, 0x18da3af1, None): [b'39390-TVA-A020\x00\x00'], (Ecu.unknown, 0x18da53f1, None): [b'77959-TVA-A460\x00\x00'], - (Ecu.unknown, 0x18da60f1, None): [b'78109-TVC-A210\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [b'78109-TVC-A210\x00\x00', b'78109-TVA-A210\x00\x00', b'78109-TVC-A010\x00\x00'], (Ecu.unknown, 0x18da61f1, None): [b'78209-TVA-A010\x00\x00'], (Ecu.unknown, 0x18dab0f1, None): [b'36802-TVA-A160\x00\x00'], (Ecu.unknown, 0x18dab5f1, None): [b'36161-TVA-A060\x00\x00'], (Ecu.unknown, 0x18daeff1, None): [b'38897-TVA-A010\x00\x00'], - } + }, + CAR.ACCORD_15: { + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-6A0-A640\x00\x00', + b'37805-6A0-A740\x00\x00', + b'37805-6A0-A840\x00\x00', + b'37805-6A0-A850\x00\x00', + b'37805-6A0-9620\x00\x00' + ], + (Ecu.unknown, 0x18da1ef1, None): [ + b'28101-6A7-A220\x00\x00', + b'28101-6A7-A320\x00\x00', + b'28101-6A7-A510\x00\x00', + ], + (Ecu.unknown, 0x18daeff1, None): [b'38897-TVA-A230\x00\x00'], + (Ecu.unknown, 0x18da2bf1, None): [b'46114-TVA-A060\x00\x00', b'46114-TVA-A120\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TVA-A010\x00\x00', + b'78109-TVA-A210\x00\x00', + b'78109-TVA-A220\x00\x00', + b'78109-TVA-A310\x00\x00', + b'78109-TWA-A210\x00\x00', + ], + (Ecu.unknown, 0x18da61f1, None): [b'78209-TVA-A010\x00\x00'], + (Ecu.unknown, 0x18dab5f1, None): [b'36161-TVA-A060\x00\x00'], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TVA-A460\x00\x00'], + (Ecu.unknown, 0x18da28f1, None): [ + b'57114-TVA-B050\x00\x00', + b'57114-TVA-B040\x00\x00', + ], + (Ecu.unknown, 0x18dab0f1, None): [ + b'36802-TVA-A150\x00\x00', + b'36802-TVA-A160\x00\x00', + b'36802-TVA-A170\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TVA-A140\x00\x00', + b'39990-TVA-A150\x00\x00', # Are these two different steerRatio? + b'39990-TVA-A160\x00\x00', # Sport, Sport 2.0T and Touring 2.0T have different ratios + ], + }, + CAR.ACCORDH: { + (Ecu.unknown, 0x18daeff1, None): [b'38897-TWA-A120\x00\x00'], + (Ecu.unknown, 0x18da28f1, None): [b'57114-TWA-A040\x00\x00'], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TWA-A440\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TWA-A010\x00\x00', + b'78109-TWA-A120\x00\x00', + b'78109-TWA-A210\x00\x00', + ], + (Ecu.unknown, 0x18da0bf1, None): [b'54008-TWA-A910\x00\x00'], + (Ecu.unknown, 0x18da61f1, None): [b'78209-TVA-A010\x00\x00'], + (Ecu.unknown, 0x18dab5f1, None): [b'36161-TWA-A070\x00\x00'], + (Ecu.unknown, 0x18dab0f1, None): [b'36802-TWA-A080\x00\x00', b'36802-TWA-A070\x00\x00'], + (Ecu.eps, 0x18da30f1, None): [b'39990-TVA-A160\x00\x00'], + }, + CAR.CIVIC: { + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-5AA-A640\x00\x00', + b'37805-5AA-A650\x00\x00', + b'37805-5AA-A810\x00\x00', + b'37805-5AA-L660\x00\x00', + b'37805-5BA-L940\x00\x00', + b'37805-5BA-L960\x00\x00', + ], + (Ecu.unknown, 0x18da1ef1, None): [ + b'28101-5CG-A040\x00\x00', + b'28101-5CG-A050\x00\x00', + b'28101-5CG-A810\x00\x00', + b'28101-5DJ-A040\x00\x00', + b'28101-5DJ-A060\x00\x00', + ], + (Ecu.unknown, 0x18da28f1, None): [ + b'57114-TBA-A550\x00\x00', + b'57114-TBA-A560\x00\x00', + b'57114-TBA-A570\x00\x00' + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TBA-A030\x00\x00', + b'39990-TBA,A030\x00\x00', + b'39990-TBG-A030\x00\x00' + ], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TBA-A030\x00\x00', b'77959-TBG-A030\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TBC-A310\x00\x00', + b'78109-TBC-A510\x00\x00', + b'78109-TBH-A530\x00\x00', + b'78109-TBC-A520\x00\x00', + ], + (Ecu.unknown, 0x18dab0f1, None): [ + b'36161-TBC-A020\x00\x00', + b'36161-TBC-A030\x00\x00', + b'36161-TBA-A030\x00\x00', + ], + (Ecu.unknown, 0x18daeff1, None): [ + b'38897-TBA-A010\x00\x00', + b'38897-TBA-A020\x00\x00', + b'36161-TBA-A030\x00\x00', + ], + }, + CAR.CIVIC_BOSCH: { + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-5AN-A750\x00\x00', + b'37805-5AN-A830\x00\x00', + b'37805-5AN-A930\x00\x00', + b'37805-5BB-L640\x00\x00', + ], + (Ecu.unknown, 0x18da1ef1, None): [ + b'28101-5CK-A130\x00\x00', + b'28101-5CK-A150\x00\x00', + b'28101-5CK-C130\x00\x00', + b'28101-5DJ-A710\x00\x00', + ], + (Ecu.unknown, 0x18da28f1, None): [b'57114-TBG-A340\x00\x00', b'57114-TGG-A340\x00\x00'], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TBA-C020\x00\x00', + b'39990-TGG-A020\x00\x00', + b'39990-TGG-A120\x00\x00', + ], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TBA-A060\x00\x00', b'77959-TGG-A020\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TBA-A910\x00\x00', + b'78109-TGG-A210\x00\x00', + b'78109-TGG-A310\x00\x00', + b'78109-TGG-A810\x00\x00', + ], + (Ecu.unknown, 0x18dab0f1, None): [b'36802-TBA-A150\x00\x00', b'36802-TGG-A050\x00\x00'], + (Ecu.unknown, 0x18dab5f1, None): [b'36161-TBA-A130\x00\x00', b'36161-TGG-A060\x00\x00'], + (Ecu.unknown, 0x18daeff1, None): [b'38897-TBA-A110\x00\x00', b'38897-TBA-A020\x00\x00'], + }, + CAR.CRV_5G: { + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-5PA-3080\x00\x00', + b'37805-5PA-A670\x00\x00', + b'37805-5PA-A850\x00\x00', + b'37805-5PA-6630\x00\x00', + b'37805-5PA-A680\x00\x00', + ], + (Ecu.unknown, 0x18da1ef1, None): [ + b'28101-5RG-A020\x00\x00', + b'28101-5RG-A040\x00\x00', + b'28101-5RH-A030\x00\x00', + b'28101-5RH-A120\x00\x00', + b'28101-5RH-A040\x00\x00', + ], + (Ecu.unknown, 0x18da28f1, None): [ + b'57114-TLA-A040\x00\x00', + b'57114-TLA-A050\x00\x00', + b'57114-TLA-A060\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [b'39990-TLA-A040\x00\x00', b'39990-TLA,A040\x00\x00'], + (Ecu.unknown, 0x18da2bf1, None): [b'46114-TLA-A040\x00\x00', b'46114-TLA-A050\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TLA-A110\x00\x00', + b'78109-TLA-A210\x00\x00', + b'78109-TLB-A110\x00\x00', + b'78109-TLB-A210\x00\x00', + ], + (Ecu.unknown, 0x18daeff1, None): [b'38897-TLA-A010\x00\x00', b'38897-TNY-G010\x00\x00'], + (Ecu.unknown, 0x18dab0f1, None): [ + b'36802-TLA-A040\x00\x00', + b'36802-TLA-A050\x00\x00', + b'36802-TLA-A060\x00\x00', + ], + (Ecu.unknown, 0x18dab5f1, None): [ + b'36161-TLA-A060\x00\x00', + b'36161-TLA-A080\x00\x00', + ], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TLA-A240\x00\x00', b'77959-TLA-A250\x00\x00'], + }, + CAR.ODYSSEY: { + (Ecu.unknown, 0x18daeff1, None): [b'38897-THR-A010\x00\x00', b'38897-THR-A020\x00\x00'], + (Ecu.unknown, 0x18da10f1, None): [ + b'37805-5MR-A250\x00\x00', + b'37805-5MR-C620\x00\x00', + b'37805-5MR-A310\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [b'39990-THR-A020\x00\x00', b'39990-THR-A030\x00\x00'], + (Ecu.unknown, 0x18da53f1, None): [b'77959-THR-A010\x00\x00', b'77959-THR-A110\x00\x00'], + (Ecu.unknown, 0x18dab0f1, None): [ + b'36161-THR-A030\x00\x00', + b'36161-THR-C010\x00\x00', + b'36161-THR-A110\x00\x00', + ], + (Ecu.unknown, 0x18da1ef1, None): [b'28101-5NZ-A310\x00\x00', b'28102-5MX-A910\x00\x00'], + (Ecu.unknown, 0x18da28f1, None): [b'57114-THR-A040\x00\x00', b'57114-THR-A110\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-THR-A230\x00\x00', + b'78109-THR-A430\x00\x00', + b'78109-THR-AL10\x00\x00', + b'78109-THR-AC40\x00\x00', + ], + (Ecu.unknown, 0x18da0bf1, None): [b'54008-THR-A020\x00\x00'], + }, + CAR.PILOT_2019: { + (Ecu.eps, 0x18da30f1, None): [b'39990-TG7-A060\x00\x00', b'39990-TGS-A230\x00\x00'], + (Ecu.unknown, 0x18daeff1, None): [b'38897-TG7-A110\x00\x00', b'38897-TG7-A030\x00\x00'], + (Ecu.unknown, 0x18dab0f1, None): [ + b'36161-TG7-A630\x00\x00', + b'36161-TG7-A930\x00\x00', + b'36161-TGS-A130\x00\x00', + b'36161-TG8-A630\x00\x00', + ], + (Ecu.unknown, 0x18da53f1, None): [b'77959-TG7-A210\x00\x00', b'77959-TGS-A010\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [ + b'78109-TG7-AJ20\x00\x00', + b'78109-TG7-AP20\x00\x00', + b'78109-TGS-AP20\x00\x00', + b'78109-TG8-AJ20\x00\x00', + ], + (Ecu.unknown, 0x18da28f1, None): [ + b'57114-TG7-A630\x00\x00', + b'57114-TG7-A730\x00\x00', + b'57114-TGS-A530\x00\x00', + b'57114-TG8-A630\x00\x00', + ], + }, + CAR.RIDGELINE: { + (Ecu.eps, 0x18da30f1, None): [b'39990-T6Z-A020\x00\x00'], + (Ecu.unknown, 0x18dab0f1, None): [b'36161-T6Z-A310\x00\x00'], + (Ecu.unknown, 0x18daeff1, None): [b'38897-T6Z-A010\x00\x00'], + (Ecu.unknown, 0x18da60f1, None): [b'78109-T6Z-A420\x00\x00'], + (Ecu.unknown, 0x18da53f1, None): [b'77959-T6Z-A020\x00\x00'], + (Ecu.unknown, 0x18da28f1, None): [b'57114-T6Z-A130\x00\x00'], + }, } DBC = { diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index ee4f38ac8e..1c2da5b043 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -239,28 +239,333 @@ FINGERPRINTS = { } FW_VERSIONS = { + CAR.AVALON: { + (Ecu.esp, 0x7b0, None): [b'F152607060\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [b'881510705200\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [b'8965B41051\x00\x00\x00\x00\x00\x00'], + (Ecu.engine, 0x7e0, None): [b'\x0230721200\x00\x00\x00\x00\x00\x00\x00\x00A0C01000\x00\x00\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4702100\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F0703000\x00\x00\x00\x00'], + }, + CAR.CAMRY: { + (Ecu.engine, 0x700, None): [ + b'\x018966333P4200\x00\x00\x00\x00', + b'\x018966333P4700\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0607200 ', + b'8821F0601300 ', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152606210\x00\x00\x00\x00\x00\x00', + b'F152606290\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [b'8965B33540\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F0607200 ', + b'8821F0601300 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601200 ', + b'8646F0601300 ', + ], + }, + CAR.CAMRYH: { + (Ecu.engine, 0x700, None): [ + b'\x028966306N8200\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306R5000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633713\x00\x00\x00\x00\x00\x00', + b'F152633B51\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0601300 ', + b'8821F0607200 ', + ], + (Ecu.eps, 0x7a1, None): [b'8965B33540\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F0601300 ', + b'8821F0607200 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601300 ', + b'8646F0605000 ', + ], + }, + CAR.COROLLA: { + (Ecu.engine, 0x7e0, None): [ + b'\x0230ZC2200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC3200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0330ZC1200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', + + ], + (Ecu.dsu, 0x791, None): [b'881510201100\x00\x00\x00\x00'], + (Ecu.esp, 0x7b0, None): [b'F152602190\x00\x00\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [ + b'8965B02181\x00\x00\x00\x00\x00\x00', + b'8965B02191\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0201101\x00\x00\x00\x00', + b'8646F0201200\x00\x00\x00\x00', + ], + }, CAR.COROLLA_TSS2: { - (Ecu.engine, 0x700, None): [b'\x01896630ZG5000\x00\x00\x00\x00'], - (Ecu.eps, 0x7a1, None): [b'\x018965B12350\x00\x00\x00\x00\x00\x00'], - (Ecu.esp, 0x7b0, None): [b'\x01F152602280\x00\x00\x00\x00\x00\x00'], - (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F3301100\x00\x00\x00\x00'], - (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F1201200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00'], + (Ecu.engine, 0x700, None): [ + b'\x01896630ZG5000\x00\x00\x00\x00', + b'\x01896630ZG5100\x00\x00\x00\x00', + b'\x01896630ZQ5000\x00\x00\x00\x00', + b'\x018966312L8000\x00\x00\x00\x00', + b'\x018966312P9000\x00\x00\x00\x00', + b'\x018966312P9100\x00\x00\x00\x00', + b'\x018966312R1000\x00\x00\x00\x00', + b'\x018966312R1100\x00\x00\x00\x00', + b'\x018966312R3100\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B12361\x00\x00\x00\x00\x00\x00', + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'\x018965B12500\x00\x00\x00\x00\x00\x00', + b'\x018965B12530\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152602280\x00\x00\x00\x00\x00\x00', + b'\x01F152602560\x00\x00\x00\x00\x00\x00', + b'\x01F152612641\x00\x00\x00\x00\x00\x00', + b'\x01F152612B10\x00\x00\x00\x00\x00\x00', + b'\x01F152612B90\x00\x00\x00\x00\x00\x00', + b'\x01F152612B60\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F12010D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1202000\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.COROLLAH_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x018966342M5000\x00\x00\x00\x00', + b'\x038966312N1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'8965B42170\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152612691\x00\x00\x00\x00\x00\x00', + b'F152642540\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDER: { + (Ecu.engine, 0x700, None): [ + b'\x01896630E83000\x00\x00\x00\x00', + b'\x01896630E85000\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [b'8965B48140\x00\x00\x00\x00\x00\x00'], + (Ecu.esp, 0x7b0, None): [b'F15260E011\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [b'881510E01200\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4702300\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F0E01200\x00\x00\x00\x00'], + }, + CAR.LEXUS_IS: { + (Ecu.engine, 0x700, None): [b'\x018966353Q2300\x00\x00\x00\x00'], + (Ecu.esp, 0x7b0, None): [b'F152653330\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [b'881515306400\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [b'8965B53271\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4702300\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F5301400\x00\x00\x00\x00'], }, CAR.PRIUS: { - (Ecu.engine, 0x700, None): [b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00'], - (Ecu.eps, 0x7a1, None): [b'8965B47023\x00\x00\x00\x00\x00\x00'], - (Ecu.esp, 0x7b0, None): [b'F152647416\x00\x00\x00\x00\x00\x00'], - (Ecu.dsu, 0x791, None): [b'881514703100\x00\x00\x00\x00'], - (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4702100\x00\x00\x00\x00'], - (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F4702100\x00\x00\x00\x00'], + (Ecu.engine, 0x700, None): [ + b'\x02896634761000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634761100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634769100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634774000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634774100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634759300\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701002\x00\x00\x00\x00', + b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703001\x00\x00\x00\x00', + b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x03896634768100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x03896634786000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', + b'\x03896634789000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x038966347A3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707001\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B47021\x00\x00\x00\x00\x00\x00', + b'8965B47022\x00\x00\x00\x00\x00\x00', + b'8965B47023\x00\x00\x00\x00\x00\x00', + b'8965B47050\x00\x00\x00\x00\x00\x00', + b'8965B47060\x00\x00\x00\x00\x00\x00', # Think this the EPS with good angle sensor + ], + (Ecu.esp, 0x7b0, None): [ + b'F152647290\x00\x00\x00\x00\x00\x00', + b'F152647310\x00\x00\x00\x00\x00\x00', + b'F152647414\x00\x00\x00\x00\x00\x00', + b'F152647415\x00\x00\x00\x00\x00\x00', + b'F152647416\x00\x00\x00\x00\x00\x00', + b'F152647417\x00\x00\x00\x00\x00\x00', + b'F152647490\x00\x00\x00\x00\x00\x00', + b'F152647684\x00\x00\x00\x00\x00\x00', + b'F152647863\x00\x00\x00\x00\x00\x00', + b'F152647864\x00\x00\x00\x00\x00\x00', + b'F152647865\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514702300\x00\x00\x00\x00', + b'881514703100\x00\x00\x00\x00', + b'881514704100\x00\x00\x00\x00', + b'881514706000\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4702001\x00\x00\x00\x00', + b'8646F4702100\x00\x00\x00\x00', + b'8646F4702200\x00\x00\x00\x00', + b'8646F4705000\x00\x00\x00\x00', + b'8646F4705200\x00\x00\x00\x00', + b'8646F4701300\x00\x00\x00\x00', + ], }, CAR.RAV4: { - (Ecu.engine, 0x7e0, None): [b'\x02342Q2100\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00'], + (Ecu.engine, 0x7e0, None): [ + b'\x02342Q2000\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2100\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q1100\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', + ], (Ecu.eps, 0x7a1, None): [b'8965B42083\x00\x00\x00\x00\x00\x00'], (Ecu.esp, 0x7b0, None): [b'F15260R103\x00\x00\x00\x00\x00\x00'], - (Ecu.dsu, 0x791, None): [b'881514201400\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [ + b'881514201300\x00\x00\x00\x00', + b'881514201400\x00\x00\x00\x00', + ], (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4702100\x00\x00\x00\x00'], - (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F4202100\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4202100\x00\x00\x00\x00', + b'8646F4202001\x00\x00\x00\x00', + ], + }, + CAR.RAV4H: { + (Ecu.engine, 0x7e0, None): [ + b'\x02342N9000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342N9100\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2000\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42163\x00\x00\x00\x00\x00\x00', + b'8965B42162\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [b'F152642120\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4201100\x00\x00\x00\x00', + b'8646F4202001\x00\x00\x00\x00', + b'8646F4202100\x00\x00\x00\x00', + b'8646F4204000\x00\x00\x00\x00', + ], + }, + CAR.RAV4_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x018966342E2000\x00\x00\x00\x00', + b'\x018966342M8000\x00\x00\x00\x00', + b'\x018966342T1000\x00\x00\x00\x00', + b'\x01896634A22000\x00\x00\x00\x00', + b'\x01F152642551\x00\x00\x00\x00\x00\x00', + b'\x028966342Y8000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F15260R210\x00\x00\x00\x00\x00\x00', + b'\x01F15260R220\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42170\x00\x00\x00\x00\x00\x00', + b'8965B42171\x00\x00\x00\x00\x00\x00', + b'\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4203200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.RAV4H_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x028966342W4001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A23001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152642531\x00\x00\x00\x00\x00\x00', + b'F152642532\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42170\x00\x00\x00\x00\x00\x00', + b'8965B42171\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ES_TSS2: { + (Ecu.engine, 0x700, None): [b'\x018966333T5100\x00\x00\x00\x00'], + (Ecu.esp, 0x7b0, None): [b'\x01F152606281\x00\x00\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [b'8965B33252\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F3301200\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F3303200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00'], + }, + CAR.LEXUS_RXH: { + (Ecu.engine, 0x7e0, None): [b'\x02348Q4000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00'], + (Ecu.esp, 0x7b0, None): [b'F152648501\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [b'881514811300\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [b'8965B0E011\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [b'8821F4701000\x00\x00\x00\x00'], + (Ecu.fwdCamera, 0x750, 0x6d): [b'8646F4801200\x00\x00\x00\x00'], } } diff --git a/selfdrive/debug/fw_query/test_fw_query_on_routes.py b/selfdrive/debug/fw_query/test_fw_query_on_routes.py new file mode 100755 index 0000000000..b079e42e89 --- /dev/null +++ b/selfdrive/debug/fw_query/test_fw_query_on_routes.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +import traceback +import sys +from tqdm import tqdm +from tools.lib.logreader import LogReader +from selfdrive.car.fw_versions import match_fw_to_car +from selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS +from selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS + + +def fw_versions_to_dict(car_fw): + fw_versions = {} + for f in car_fw: + addr = f.address + subaddr = f.subAddress + if subaddr == 0: + subaddr = None + fw_versions[(addr, subaddr)] = f.fwVersion + + return fw_versions + + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: ./test_fw_query_on_routes.py ") + sys.exit(1) + + i = 0 + dongles = [] + for route in tqdm(list(open(sys.argv[1]))): + route = route.rstrip() + dongle_id, time = route.split('|') + qlog_path = f"cd:/{dongle_id}/{time}/0/qlog.bz2" + + if dongle_id in dongles: + continue + + try: + lr = LogReader(qlog_path) + + for msg in lr: + if msg.which() == "health": + if msg.health.hwType not in ['uno', 'blackPanda']: + dongles.append(dongle_id) + break + + elif msg.which() == "carParams": + car_fw = msg.carParams.carFw + if len(car_fw) == 0: + break + + dongles.append(dongle_id) + live_fingerprint = msg.carParams.carFingerprint + + if live_fingerprint not in list(TOYOTA_FW_VERSIONS.keys()) + list(HONDA_FW_VERSIONS.keys()): + continue + + fw_versions = fw_versions_to_dict(car_fw) + candidates = match_fw_to_car(fw_versions) + if (len(candidates) == 1) and (list(candidates)[0] == live_fingerprint): + print("Correct", live_fingerprint, dongle_id) + break + + print(f"{dongle_id}|{time}") + print("Old style:", live_fingerprint, "Vin", msg.carParams.carVin) + print("New style:", candidates) + + for version in car_fw: + subaddr = None if version.subAddress == 0 else hex(version.subAddress) + print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],") + + print("Mismatches") + for car_fws in [TOYOTA_FW_VERSIONS, HONDA_FW_VERSIONS]: + if live_fingerprint in car_fws: + + expected = car_fws[live_fingerprint] + for (_, expected_addr, expected_sub_addr), v in expected.items(): + for version in car_fw: + sub_addr = None if version.subAddress == 0 else version.subAddress + addr = version.address + + if (addr, sub_addr) == (expected_addr, expected_sub_addr): + if version.fwVersion not in v: + print(f"({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}) - {version.fwVersion}") + + print() + i += 1 + break + except Exception: + traceback.print_exc() + + print(f"Unfingerprinted cars: {i}") + print(f"Number of dongle ids checked: {len(dongles)}")