mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-09-30 03:13:53 +08:00
CAN fingerprinting test (#29427)
* timing test
* test
* fix
* print
* loop
* clean up
* wider range
* Update selfdrive/car/tests/test_models.py
* Apply suggestions from code review
* run many times
* Update selfdrive/car/tests/test_models.py
* run for many its
* run with unittest and print as list
* Update .github/workflows/selfdrive_tests.yaml
* Update .github/workflows/selfdrive_tests.yaml
* total time is super inconsistent (body)
* Update selfdrive/car/tests/test_models.py
* clean up
* clean up
* clean up
* this works!
* draft
* test suite not as modular
* try something like this
* can do kb, but not too representative
* clean up
* remove kb? it depends on signals
* clean up
* more clean up
* rename
* just measure all CANParsers
* can do all this manually
* but this is way simpler
* comment
* stash
* draft
* draft
* remove old script
* clean up
* revert
* use it
* remove test
* opt
* no partial
* remove
* revert test_models
* test can fingerprinting
* so much simpler!
* fix dict resizing
* simplify
* need to do this
* fix
* move to new file
* rename
* comment
* ignore function-uses-loop-variable
old-commit-hash: fd8f8d8785
This commit is contained in:
@@ -212,10 +212,10 @@ FINGERPRINTS = {
|
||||
}],
|
||||
# Trailblazer also matches as a Silverado, so comment out to avoid conflicts.
|
||||
# TODO: split with FW versions
|
||||
CAR.TRAILBLAZER: [
|
||||
{
|
||||
# CAR.TRAILBLAZER: [
|
||||
# {
|
||||
# 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 3, 309: 8, 311: 8, 313: 8, 320: 4, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 500: 6, 501: 8, 532: 6, 560: 8, 562: 8, 563: 5, 565: 5, 587: 8, 707: 8, 715: 8, 717: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 869: 4, 880: 6, 977: 8, 1001: 8, 1011: 6, 1017: 8, 1020: 8, 1217: 8, 1221: 5, 1233: 8, 1249: 8, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1609: 8, 1611: 8, 1613: 8, 1649: 8, 1792: 8, 1798: 8, 1824: 8, 1825: 8, 1840: 8, 1842: 8, 1858: 8, 1860: 8, 1863: 8, 1872: 8, 1875: 8, 1882: 8, 1888: 8, 1889: 8, 1892: 8, 1930: 7, 1937: 8, 1953: 8, 1968: 8, 2001: 8, 2017: 8, 2018: 8, 2020: 8
|
||||
}],
|
||||
# }],
|
||||
}
|
||||
|
||||
GM_RX_OFFSET = 0x400
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
from parameterized import parameterized
|
||||
import unittest
|
||||
|
||||
from cereal import log, messaging
|
||||
from selfdrive.car.car_helpers import can_fingerprint
|
||||
from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS
|
||||
|
||||
|
||||
class TestCanFingerprint(unittest.TestCase):
|
||||
@parameterized.expand([(c, f) for c, f in FINGERPRINTS.items()])
|
||||
def test_can_fingerprint(self, car_model, fingerprints):
|
||||
# Tests online fingerprinting function on offline fingerprints
|
||||
for fingerprint in fingerprints: # can have multiple fingerprints for each platform
|
||||
can = messaging.new_message('can', 1)
|
||||
can.can = [log.CanData(address=address, dat=b'\x00' * length)
|
||||
for address, length in fingerprint.items()]
|
||||
|
||||
fingerprint_iter = iter([can])
|
||||
empty_can = messaging.new_message('can', 0)
|
||||
car_fingerprint, finger = can_fingerprint(lambda: next(fingerprint_iter, empty_can)) # noqa: B023
|
||||
|
||||
self.assertEqual(car_fingerprint, car_model)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user