From abf2801122a8e92e486a8ca88c946949d3149bae Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Tue, 23 Jan 2024 20:59:32 -0800 Subject: [PATCH] use get_first_message for auto_fingerprint --- tools/car_porting/auto_fingerprint.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/car_porting/auto_fingerprint.py b/tools/car_porting/auto_fingerprint.py index fce7e33182..e14a018917 100755 --- a/tools/car_porting/auto_fingerprint.py +++ b/tools/car_porting/auto_fingerprint.py @@ -7,7 +7,7 @@ from openpilot.selfdrive.debug.format_fingerprints import format_brand_fw_versio from openpilot.selfdrive.car.fw_versions import match_fw_to_car from openpilot.selfdrive.car.interfaces import get_interface_attr -from openpilot.tools.lib.logreader import LogReader, ReadMode +from openpilot.tools.lib.logreader import LogReader, ReadMode, get_first_message ALL_FW_VERSIONS = get_interface_attr("FW_VERSIONS") @@ -32,16 +32,15 @@ if __name__ == "__main__": platform: Optional[str] = None - for msg in lr: - if msg.which() == "carParams": - carFw = msg.carParams.carFw - carVin = msg.carParams.carVin - carPlatform = msg.carParams.carFingerprint - break + CP = get_first_message(lr, "carParams") - if carFw is None: + if CP is None: raise Exception("No fw versions in the provided route...") + carFw = CP.carParams.carFw + carVin = CP.carParams.carVin + carPlatform = CP.carParams.carFingerprint + if args.platform is None: # attempt to auto-determine platform with other fuzzy fingerprints _, possible_platforms = match_fw_to_car(carFw, log=False)