From c083ef8f876bcc11aaec5430d3809ff1e2a49d52 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 7 Jun 2023 18:09:55 -0700 Subject: [PATCH] clean up (utils are cleaner and less buggy) --- selfdrive/car/hyundai/tests/test_hyundai.py | 2 +- selfdrive/car/hyundai/values.py | 23 +-------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 3a9a37cef8..b25395dacc 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -36,7 +36,7 @@ class TestHyundaiFingerprint(unittest.TestCase): self.assertIn(fuzzy_ecu, [e[0] for e in ecus]) def test_fuzzy_fw_dates(self): - # Some newer CAN FD platforms have date codes in a different format we don't yet parse, + # Some newer platforms have date codes in a different format we don't yet parse, # for now assert date format is consistent across each platform for car_model, ecus in FW_VERSIONS.items(): with self.subTest(car_model=car_model): diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 0e1eb1f761..0bb6c9df4a 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1,6 +1,5 @@ import re from datetime import datetime -from dateutil.relativedelta import relativedelta from dateutil import rrule from collections import defaultdict from dataclasses import dataclass @@ -347,7 +346,6 @@ FINGERPRINTS = { }], } -import time def get_platform_codes(fw_versions: List[bytes]) -> Set[bytes]: # platform_code_pattern = re.compile(b'(?<=' + HYUNDAI_VERSION_REQUEST_LONG[1:] + b')[A-Z]{2}[A-Za-z0-9]{0,2}') @@ -367,30 +365,11 @@ def get_platform_codes(fw_versions: List[bytes]) -> Set[bytes]: final_codes.add(code) continue - delta = relativedelta(months=1) dates = {datetime.strptime(date.decode()[:4], '%y%m') for date in dates} for date in rrule.rrule(rrule.MONTHLY, dtstart=min(dates), until=max(dates)): final_codes.add(code + b'_' + date.strftime('%y%m').encode()) - return final_codes - # # current_date = datetime.strptime(max(dates).decode(), '%y%m%d') - # # max_date = datetime.strptime(max(dates).decode(), '%y%m%d') - # print('code, dates:', code, datesp) - # - # min_date, max_date = min(dates), max(dates) - # current_year, current_month = int(min_date[:2]), int(min_date[2:4]) - # max_year, max_month = int(max_date[:2]), int(max_date[2:4]) - # # print(current_year, current_month, max_year, max_month) - # # return set() - # while current_year < max_year or current_month < max_month: - # time.sleep(0.1) - # print(current_month, current_year, max_month, max_year) - # date_code = str(current_year).zfill(2) + str(current_month).zfill(2) - # final_codes.add(code + b'_' + date_code.encode()) - # current_year += (current_month + 1) // 13 - # current_month = (current_month % 12) + 1 - # - # return final_codes + return final_codes HYUNDAI_VERSION_REQUEST_LONG = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \