Skip to content

Commit

Permalink
Volkswagen: test FW version format (commaai#32162)
Browse files Browse the repository at this point in the history
* add test

* more explicit
  • Loading branch information
sshane authored Apr 11, 2024
1 parent c1edc09 commit 70b8e27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions selfdrive/car/volkswagen/tests/test_volkswagen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
import unittest

from openpilot.selfdrive.car.volkswagen.values import SPARE_PART_FW_PATTERN
from openpilot.selfdrive.car.volkswagen.fingerprints import FW_VERSIONS


class TestVolkswagenPlatformConfigs(unittest.TestCase):
def test_spare_part_fw_pattern(self):
# Relied on for determining if a FW is likely VW
for platform, ecus in FW_VERSIONS.items():
with self.subTest(platform=platform):
for fws in ecus.values():
for fw in fws:
self.assertNotEqual(SPARE_PART_FW_PATTERN.match(fw), None, f"Bad FW: {fw}")


if __name__ == "__main__":
unittest.main()
4 changes: 4 additions & 0 deletions selfdrive/car/volkswagen/values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import namedtuple
from dataclasses import dataclass, field
from enum import Enum, IntFlag
import re

from cereal import car
from panda.python import uds
Expand Down Expand Up @@ -362,6 +363,9 @@ class CAR(Platforms):

VOLKSWAGEN_RX_OFFSET = 0x6a

# TODO: determine the unknown groups
SPARE_PART_FW_PATTERN = re.compile(b'\xf1\x87(?P<gateway>[0-9][0-9A-Z]{2})(?P<unknown>[0-9][0-9A-Z][0-9])(?P<unknown2>[0-9A-Z]{2}[0-9])([A-Z0-9]| )')

FW_QUERY_CONFIG = FwQueryConfig(
# TODO: add back whitelists after we gather enough data
requests=[request for bus, obd_multiplexing in [(1, True), (1, False), (0, False)] for request in [
Expand Down

0 comments on commit 70b8e27

Please sign in to comment.