diff --git a/opendbc/car/debug/format_fingerprints.py b/opendbc/car/debug/format_fingerprints.py new file mode 100755 index 0000000000..a94d7aa5cc --- /dev/null +++ b/opendbc/car/debug/format_fingerprints.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +import jinja2 +import os + +from opendbc.car.common.basedir import BASEDIR +from opendbc.car.interfaces import get_interface_attr +from opendbc.car.structs import CarParams + +Ecu = CarParams.Ecu + +CARS = get_interface_attr('CAR') +FW_VERSIONS = get_interface_attr('FW_VERSIONS') +FINGERPRINTS = get_interface_attr('FINGERPRINTS') +ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} + +FINGERPRINTS_PY_TEMPLATE = jinja2.Template(""" +{%- if FINGERPRINTS[brand] %} +# ruff: noqa: E501 +{% endif %} +{% if FW_VERSIONS[brand] %} +from opendbc.car.structs import CarParams +{% endif %} +from opendbc.car.{{brand}}.values import CAR +{% if FW_VERSIONS[brand] %} + +Ecu = CarParams.Ecu +{% endif %} +{% if comments +%} +{{ comments | join() }} +{% endif %} +{% if FINGERPRINTS[brand] %} + +FINGERPRINTS = { +{% for car, fingerprints in FINGERPRINTS[brand].items() %} + CAR.{{car.name}}: [{ +{% for fingerprint in fingerprints %} +{% if not loop.first %} + {{ "{" }} +{% endif %} + {% for key, value in fingerprint.items() %}{{key}}: {{value}}{% if not loop.last %}, {% endif %}{% endfor %} + + }{% if loop.last %}]{% endif %}, +{% endfor %} +{% endfor %} +} +{% endif %} + +FW_VERSIONS{% if not FW_VERSIONS[brand] %}: dict[str, dict[tuple, list[bytes]]]{% endif %} = { +{% for car, _ in FW_VERSIONS[brand].items() %} + CAR.{{car.name}}: { +{% for key, fw_versions in FW_VERSIONS[brand][car].items() %} + (Ecu.{{ECU_NAME[key[0]]}}, 0x{{"%0x" | format(key[1] | int)}}, \ +{% if key[2] %}0x{{"%0x" | format(key[2] | int)}}{% else %}{{key[2]}}{% endif %}): [ + {% for fw_version in (fw_versions + extra_fw_versions.get(car, {}).get(key, [])) | unique | sort %} + {{fw_version}}, + {% endfor %} + ], +{% endfor %} + }, +{% endfor %} +} + +""", trim_blocks=True) + + +def format_brand_fw_versions(brand, extra_fw_versions: None | dict[str, dict[tuple, list[bytes]]] = None): + extra_fw_versions = extra_fw_versions or {} + + fingerprints_file = os.path.join(BASEDIR, f"{brand}/fingerprints.py") + with open(fingerprints_file) as f: + comments = [line for line in f.readlines() if line.startswith("#") and "noqa" not in line] + + with open(fingerprints_file, "w") as f: + f.write(FINGERPRINTS_PY_TEMPLATE.render(brand=brand, comments=comments, ECU_NAME=ECU_NAME, + FINGERPRINTS=FINGERPRINTS, FW_VERSIONS=FW_VERSIONS, + extra_fw_versions=extra_fw_versions)) + + +if __name__ == "__main__": + for brand in FW_VERSIONS.keys(): + format_brand_fw_versions(brand) diff --git a/opendbc/car/honda/fingerprints.py b/opendbc/car/honda/fingerprints.py index f8d872d155..56e41ab434 100644 --- a/opendbc/car/honda/fingerprints.py +++ b/opendbc/car/honda/fingerprints.py @@ -867,10 +867,10 @@ b'39990-T39-A130\x00\x00', b'39990-T43-J020\x00\x00', b'39990-T43-J030\x00\x00', - b'39990-T60-J030\x00\x00', - b'39990-T56-A040\x00\x00', b'39990-T50-J030\x00\x00', b'39990-T50-J110\x00\x00', + b'39990-T56-A040\x00\x00', + b'39990-T60-J030\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-T20-A020\x00\x00', @@ -881,10 +881,10 @@ b'38897-T22-A110\x00\x00', b'38897-T24-Z120\x00\x00', b'38897-T47-AA20\x00\x00', - b'38897-T60-A110\x00\x00', - b'38897-T61-A320\x00\x00', b'38897-T50-E310\x00\x00', b'38897-T50-EA10\x00\x00', + b'38897-T60-A110\x00\x00', + b'38897-T61-A320\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-T20-A970\x00\x00', @@ -893,11 +893,11 @@ b'77959-T39-A910\x00\x00', b'77959-T47-A940\x00\x00', b'77959-T47-A950\x00\x00', + b'77959-T50-G010\x00\x00', + b'77959-T50-G930\x00\x00', b'77959-T60-A920\x00\x00', b'77959-T61-A920\x00\x00', - b'77959-T50-G930\x00\x00', b'77959-T65-A920\x00\x00', - b'77959-T50-G010\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36161-T20-A060\x00\x00', @@ -907,14 +907,14 @@ b'36161-T38-A060\x00\x00', b'36161-T47-A050\x00\x00', b'36161-T47-A070\x00\x00', - b'8S102-T47-AA20\x00\x00', b'8S102-T20-AA10\x00\x00', + b'8S102-T43-J540\x00\x00', b'8S102-T47-AA10\x00\x00', - b'8S102-T60-AA10\x00\x00', - b'8S102-T56-A060\x00\x00', + b'8S102-T47-AA20\x00\x00', b'8S102-T50-EA10\x00\x00', + b'8S102-T56-A060\x00\x00', + b'8S102-T60-AA10\x00\x00', b'8S102-T64-A040\x00\x00', - b'8S102-T43-J540\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-T20-AB40\x00\x00', @@ -922,9 +922,9 @@ b'57114-T38-AA20\x00\x00', b'57114-T43-JA30\x00\x00', b'57114-T43-JB30\x00\x00', + b'57114-T50-JC20\x00\x00', b'57114-T60-AA20\x00\x00', b'57114-T61-AJ30\x00\x00', - b'57114-T50-JC20\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-65D-A020\x00\x00', diff --git a/opendbc/car/hyundai/fingerprints.py b/opendbc/car/hyundai/fingerprints.py index 6f4ca692bf..1a40445326 100644 --- a/opendbc/car/hyundai/fingerprints.py +++ b/opendbc/car/hyundai/fingerprints.py @@ -58,8 +58,8 @@ (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00AEH MFC AT EUR LHD 1.00 1.00 95740-G2400 180222', b'\xf1\x00AEH MFC AT EUR LHD 1.00 1.00 95740-G7200 160418', - b'\xf1\x00AEH MFC AT USA LHD 1.00 1.00 95740-G2400 180222', b'\xf1\x00AEH MFC AT EUR RHD 1.00 1.00 95740-G2400 180222', + b'\xf1\x00AEH MFC AT USA LHD 1.00 1.00 95740-G2400 180222', ], }, CAR.HYUNDAI_IONIQ_PHEV_2019: { @@ -141,8 +141,8 @@ }, CAR.HYUNDAI_IONIQ_HEV_2022: { (Ecu.fwdRadar, 0x7d0, None): [ - b'\xf1\x00AEhe SCC F-CUP 1.00 1.02 99110-G2100 ', b'\xf1\x00AEhe SCC F-CUP 1.00 1.00 99110-G2600 ', + b'\xf1\x00AEhe SCC F-CUP 1.00 1.02 99110-G2100 ', b'\xf1\x00AEhe SCC FHCUP 1.00 1.00 99110-G2600 ', b'\xf1\x00AEhe SCC FHCUP 1.00 1.02 99110-G2100 ', ], @@ -151,8 +151,8 @@ b'\xf1\x00AE MDPS C 1.00 1.01 56310G2510\x00 4APHC101', ], (Ecu.fwdCamera, 0x7c4, None): [ - b'\xf1\x00AEH MFC AT USA LHD 1.00 1.01 95740-G2600 190819', b'\xf1\x00AEH MFC AT USA LHD 1.00 1.00 95740-G2700 201027', + b'\xf1\x00AEH MFC AT USA LHD 1.00 1.01 95740-G2600 190819', ], }, CAR.HYUNDAI_SONATA: { @@ -279,8 +279,8 @@ b'\xf1\x00TM ESC \x04 101 \x08\x04 58910-S2GA0', b'\xf1\x00TM ESC \x04 102!\x04\x05 58910-S2GA0', b'\xf1\x00TM ESC \x04 103"\x07\x08 58910-S2GA0', - b'\xf1\x00TM ESC \x1e 102 \x08\x08 58910-S1DA0', b'\xf1\x00TM ESC \x1b 102 \x08\x08 58910-S1DA0', + b'\xf1\x00TM ESC \x1e 102 \x08\x08 58910-S1DA0', b'\xf1\x00TM ESC 103!\x030 58910-S1MA0', ], (Ecu.eps, 0x7d4, None): [ @@ -733,14 +733,14 @@ }, CAR.KIA_NIRO_EV_2ND_GEN: { (Ecu.fwdRadar, 0x7d0, None): [ - b'\xf1\x00SG__ RDR ----- 1.00 1.00 99110-AT200 ', b'\xf1\x00SG2_ RDR ----- 1.00 1.01 99110-AT000 ', + b'\xf1\x00SG__ RDR ----- 1.00 1.00 99110-AT200 ', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00SG2EMFC AT EUR LHD 1.00 1.00 99211-AT200 240315', b'\xf1\x00SG2EMFC AT EUR LHD 1.01 1.09 99211-AT000 220801', - b'\xf1\x00SG2EMFC AT USA LHD 1.01 1.09 99211-AT000 220801', b'\xf1\x00SG2EMFC AT USA LHD 1.00 1.00 99211-AT200 240401', + b'\xf1\x00SG2EMFC AT USA LHD 1.01 1.09 99211-AT000 220801', ], }, CAR.KIA_NIRO_PHEV: { @@ -1049,9 +1049,9 @@ }, CAR.HYUNDAI_TUCSON_4TH_GEN: { (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00NX4 FR_CMR AT CAN LHD 1.00 1.00 99211-N9220 14K', b'\xf1\x00NX4 FR_CMR AT CAN LHD 1.00 1.00 99211-N9260 14Y', b'\xf1\x00NX4 FR_CMR AT CAN LHD 1.00 1.01 99211-N9100 14A', - b'\xf1\x00NX4 FR_CMR AT CAN LHD 1.00 1.00 99211-N9220 14K', b'\xf1\x00NX4 FR_CMR AT EUR LHD 1.00 1.00 99211-N9220 14K', b'\xf1\x00NX4 FR_CMR AT EUR LHD 1.00 2.02 99211-N9000 14E', b'\xf1\x00NX4 FR_CMR AT USA LHD 1.00 1.00 99211-N9210 14G', @@ -1232,16 +1232,16 @@ b'\xf1\x00OSP LKA AT USA LHD 1.00 1.04 99211-J9200 904', ], (Ecu.eps, 0x7d4, None): [ - b'\xf1\x00OSP MDPS C 1.00 1.04 56310/J9291 4OPCC104', b'\xf1\x00OSP MDPS C 1.00 1.04 56310/J9290 4OPCC104', + b'\xf1\x00OSP MDPS C 1.00 1.04 56310/J9291 4OPCC104', ], (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00YB__ FCA ----- 1.00 1.01 99110-J9000 \x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00T01960BL T01E60A1 DOS2T16X4XE60NS4N\x90\xe6\xcb', b'\xf1\x00T01G00BL T01I00A1 DOS2T16X2XI00NS0\x8c`\xff\xe7', b'\xf1\x00T01G00BL T01I00A1 DOS2T16X4XI00NS0\x99L\xeeq', - b'\xf1\x00T01960BL T01E60A1 DOS2T16X4XE60NS4N\x90\xe6\xcb', ], }, } diff --git a/opendbc/car/mazda/fingerprints.py b/opendbc/car/mazda/fingerprints.py index 8b20cad903..a573760532 100644 --- a/opendbc/car/mazda/fingerprints.py +++ b/opendbc/car/mazda/fingerprints.py @@ -13,6 +13,7 @@ b'PEW5-188K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PW67-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PW67-188K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PW8F-188K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2C-188K2-G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2D-188K2-G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2G-188K2-H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', @@ -23,7 +24,6 @@ b'PXFG-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXGC-188K2-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'SH54-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', - b'PW8F-188K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'K131-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', @@ -49,8 +49,8 @@ b'PYB2-21PS1-H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB2-21PS1-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYJ3-21PS1-H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', - b'SH51-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYJ3-21PS1-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'SH51-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], }, CAR.MAZDA_CX5: { @@ -270,7 +270,7 @@ b'PXM4-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXM6-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXM7-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', - b'PXM7-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + b'PXM7-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], }, } diff --git a/opendbc/car/subaru/fingerprints.py b/opendbc/car/subaru/fingerprints.py index 51c01e1030..a412d1b4c3 100644 --- a/opendbc/car/subaru/fingerprints.py +++ b/opendbc/car/subaru/fingerprints.py @@ -68,8 +68,8 @@ ], (Ecu.engine, 0x7e0, None): [ b'\xde"a0\x07', - b'\xe2"a0\x07', b'\xde,\xa0@\x07', + b'\xe2"a0\x07', b'\xe2"aq\x07', b'\xe2,\xa0@\x07', ], @@ -498,8 +498,8 @@ b'\xe2"`0\x07', b'\xe2"`p\x07', b'\xe2"`q\x07', - b'\xe3,\xa0@\x07', b'\xe2,\xa0p\x07', + b'\xe3,\xa0@\x07', ], (Ecu.transmission, 0x7e1, None): [ b'\xa5\xf6D@\x00', diff --git a/opendbc/car/tesla/fingerprints.py b/opendbc/car/tesla/fingerprints.py index 7477c4eeac..e12ba1eceb 100644 --- a/opendbc/car/tesla/fingerprints.py +++ b/opendbc/car/tesla/fingerprints.py @@ -29,8 +29,8 @@ b'TeMYG4_DCS_Update_0.0.0 (13),Y4P002.27.1', b'TeMYG4_DCS_Update_0.0.0 (9),Y4P002.25.0', b'TeMYG4_Legacy3Y_0.0.0 (2),Y4003.02.0', - b'TeMYG4_Legacy3Y_0.0.0 (5),Y4003.03.2', b'TeMYG4_Legacy3Y_0.0.0 (2),Y4P003.02.0', + b'TeMYG4_Legacy3Y_0.0.0 (5),Y4003.03.2', b'TeMYG4_Legacy3Y_0.0.0 (5),Y4P003.03.2', b'TeMYG4_SingleECU_0.0.0 (28),Y4S002.23.0', b'TeMYG4_SingleECU_0.0.0 (33),Y4S002.26',