|
|
|
@ -2,28 +2,24 @@ |
|
|
|
|
import jinja2 |
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
from cereal import car |
|
|
|
|
from openpilot.common.basedir import BASEDIR |
|
|
|
|
from openpilot.selfdrive.car.interfaces import get_interface_attr |
|
|
|
|
|
|
|
|
|
Ecu = car.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 cereal import car |
|
|
|
|
from openpilot.selfdrive.car.data_structures import CarParams |
|
|
|
|
{% endif %} |
|
|
|
|
from openpilot.selfdrive.car.{{brand}}.values import CAR |
|
|
|
|
{% if FW_VERSIONS[brand] %} |
|
|
|
|
|
|
|
|
|
Ecu = car.CarParams.Ecu |
|
|
|
|
Ecu = CarParams.Ecu |
|
|
|
|
{% endif %} |
|
|
|
|
{% if comments +%} |
|
|
|
|
{{ comments | join() }} |
|
|
|
@ -49,7 +45,7 @@ FW_VERSIONS{% if not FW_VERSIONS[brand] %}: dict[str, dict[tuple, list[bytes]]]{ |
|
|
|
|
{% 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)}}, \ |
|
|
|
|
(Ecu.{{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}}, |
|
|
|
@ -71,9 +67,8 @@ def format_brand_fw_versions(brand, extra_fw_versions: None | dict[str, dict[tup |
|
|
|
|
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)) |
|
|
|
|
f.write(FINGERPRINTS_PY_TEMPLATE.render(brand=brand, comments=comments, FINGERPRINTS=FINGERPRINTS, |
|
|
|
|
FW_VERSIONS=FW_VERSIONS, extra_fw_versions=extra_fw_versions)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|