mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-10-01 03:43:42 +08:00
Big batch of FW versions (#1682)
* wip big batch of fw versions * Add the rest * And two more
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# type: ignore
|
||||
|
||||
from collections import defaultdict
|
||||
import argparse
|
||||
import os
|
||||
import traceback
|
||||
@@ -9,9 +10,11 @@ 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
|
||||
from selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS
|
||||
|
||||
from selfdrive.car.toyota.values import FINGERPRINTS as TOYOTA_FINGERPRINTS
|
||||
from selfdrive.car.honda.values import FINGERPRINTS as HONDA_FINGERPRINTS
|
||||
from selfdrive.car.hyundai.values import FINGERPRINTS as HYUNDAI_FINGERPRINTS
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -25,6 +28,8 @@ if __name__ == "__main__":
|
||||
else:
|
||||
routes = [args.route]
|
||||
|
||||
mismatches = defaultdict(list)
|
||||
|
||||
wrong = 0
|
||||
good = 0
|
||||
|
||||
@@ -47,6 +52,8 @@ if __name__ == "__main__":
|
||||
break
|
||||
|
||||
elif msg.which() == "carParams":
|
||||
bts = msg.carParams.as_builder().to_bytes()
|
||||
|
||||
car_fw = msg.carParams.carFw
|
||||
if len(car_fw) == 0:
|
||||
break
|
||||
@@ -57,7 +64,7 @@ if __name__ == "__main__":
|
||||
if args.car is not None:
|
||||
live_fingerprint = args.car
|
||||
|
||||
if live_fingerprint not in list(TOYOTA_FINGERPRINTS.keys()) + list(HONDA_FINGERPRINTS.keys()):
|
||||
if live_fingerprint not in list(TOYOTA_FINGERPRINTS.keys()) + list(HONDA_FINGERPRINTS.keys()) + list(HYUNDAI_FINGERPRINTS.keys()):
|
||||
continue
|
||||
|
||||
candidates = match_fw_to_car(car_fw)
|
||||
@@ -75,9 +82,10 @@ if __name__ == "__main__":
|
||||
print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],")
|
||||
|
||||
print("Mismatches")
|
||||
for car_fws in [TOYOTA_FW_VERSIONS, HONDA_FW_VERSIONS]:
|
||||
found = False
|
||||
for car_fws in [TOYOTA_FW_VERSIONS, HONDA_FW_VERSIONS, HYUNDAI_FW_VERSIONS]:
|
||||
if live_fingerprint in car_fws:
|
||||
|
||||
found = True
|
||||
expected = car_fws[live_fingerprint]
|
||||
for (_, expected_addr, expected_sub_addr), v in expected.items():
|
||||
for version in car_fw:
|
||||
@@ -88,11 +96,42 @@ if __name__ == "__main__":
|
||||
if version.fwVersion not in v:
|
||||
print(f"({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}) - {version.fwVersion}")
|
||||
|
||||
# Add to global list of mismatches
|
||||
mismatch = (addr, sub_addr, version.fwVersion)
|
||||
if mismatch not in mismatches[live_fingerprint]:
|
||||
mismatches[live_fingerprint].append(mismatch)
|
||||
|
||||
# No FW versions for this car yet, add them all to mismatch list
|
||||
if not found:
|
||||
for version in car_fw:
|
||||
sub_addr = None if version.subAddress == 0 else version.subAddress
|
||||
addr = version.address
|
||||
mismatch = (addr, sub_addr, version.fwVersion)
|
||||
if mismatch not in mismatches[live_fingerprint]:
|
||||
mismatches[live_fingerprint].append(mismatch)
|
||||
|
||||
print()
|
||||
wrong += 1
|
||||
break
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
|
||||
print(f"Fingerprinted: {good} - Not fingerprinted: {wrong}")
|
||||
print(f"Number of dongle ids checked: {len(dongles)}")
|
||||
print()
|
||||
|
||||
# Print FW versions that need to be added seperated out by car and address
|
||||
for car, m in mismatches.items():
|
||||
print(car)
|
||||
addrs = defaultdict(list)
|
||||
for (addr, sub_addr, version) in m:
|
||||
addrs[(addr, sub_addr)].append(version)
|
||||
|
||||
for (addr, sub_addr), versions in addrs.items():
|
||||
print(f" ({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}): [")
|
||||
for v in versions:
|
||||
print(f" {v},")
|
||||
print(" ]")
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user