Skip to content

Commit

Permalink
Fingerprint rav4 hybrid tss2 only using firmware versions (#1084)
Browse files Browse the repository at this point in the history
* fingerprint rav4 hybrid tsss only using firmware

* remove print statement
  • Loading branch information
pd0wm committed Feb 12, 2020
1 parent a0da739 commit 9e6e1cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cereal
5 changes: 5 additions & 0 deletions selfdrive/car/car_helpers.py
Expand Up @@ -133,6 +133,11 @@ def fingerprint(logcan, sendcan, has_relay):
car_fingerprint = list(fw_candidates)[0] car_fingerprint = list(fw_candidates)[0]
source = car.CarParams.FingerprintSource.fw source = car.CarParams.FingerprintSource.fw


fixed_fingerprint = os.environ.get('FINGERPRINT', "")
if len(fixed_fingerprint):
car_fingerprint = fixed_fingerprint
source = car.CarParams.FingerprintSource.fixed

cloudlog.warning("fingerprinted %s", car_fingerprint) cloudlog.warning("fingerprinted %s", car_fingerprint)
return car_fingerprint, finger, vin, car_fw, source return car_fingerprint, finger, vin, car_fw, source


Expand Down
32 changes: 14 additions & 18 deletions selfdrive/car/fingerprints.py
@@ -1,11 +1,12 @@
import os import os
from common.basedir import BASEDIR from common.basedir import BASEDIR


def get_attr_from_cars(attr):
def get_attr_from_cars(attr, result=dict):
# read all the folders in selfdrive/car and return a dict where: # read all the folders in selfdrive/car and return a dict where:
# - keys are all the car models # - keys are all the car models
# - values are attr values from all car folders # - values are attr values from all car folders
result = {} result = result()


for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]: for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]:
try: try:
Expand All @@ -16,29 +17,21 @@ def get_attr_from_cars(attr):
else: else:
continue continue


for f, v in attr_values.items(): if isinstance(attr_values, dict):
result[f] = v for f, v in attr_values.items():
result[f] = v
elif isinstance(attr_values, list):
result += attr_values


except (ImportError, IOError): except (ImportError, IOError):
pass pass


return result return result




def get_fw_versions_list(): FW_VERSIONS = get_attr_from_cars('FW_VERSIONS')
return get_attr_from_cars('FW_VERSIONS') _FINGERPRINTS = get_attr_from_cars('FINGERPRINTS')

IGNORED_FINGERPRINTS = get_attr_from_cars('IGNORED_FINGERPRINTS', list)

def get_fingerprint_list():
# read all the folders in selfdrive/car and return a dict where:
# - keys are all the car models for which we have a fingerprint
# - values are lists dicts of messages that constitute the unique
# CAN fingerprint of each car model and all its variants
return get_attr_from_cars('FINGERPRINTS')


FW_VERSIONS = get_fw_versions_list()
_FINGERPRINTS = get_fingerprint_list()


_DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes _DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes


Expand All @@ -61,6 +54,9 @@ def eliminate_incompatible_cars(msg, candidate_cars):
compatible_cars = [] compatible_cars = []


for car_name in candidate_cars: for car_name in candidate_cars:
if car_name in IGNORED_FINGERPRINTS:
continue

car_fingerprints = _FINGERPRINTS[car_name] car_fingerprints = _FINGERPRINTS[car_name]


for fingerprint in car_fingerprints: for fingerprint in car_fingerprints:
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/toyota/values.py
Expand Up @@ -257,10 +257,7 @@ class CAR:
{ {
36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913:8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913:8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}, },
# German Lounge ],
{
36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1800: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8
}],
CAR.LEXUS_CTH: [{ CAR.LEXUS_CTH: [{
36: 8, 37: 8, 170: 8, 180: 8, 288: 8, 426: 6, 452: 8, 466: 8, 467: 8, 548: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 810: 2, 832: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 950: 8, 951: 8, 953: 3, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1116: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 36: 8, 37: 8, 170: 8, 180: 8, 288: 8, 426: 6, 452: 8, 466: 8, 467: 8, 548: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 810: 2, 832: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 950: 8, 951: 8, 953: 3, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1116: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}], }],
Expand All @@ -269,6 +266,9 @@ class CAR:
}] }]
} }


# Don't use theses fingerprints for fingerprinting, they are still needed for ECU detection
IGNORED_FINGERPRINTS = [CAR.RAV4H_TSS2]

FW_VERSIONS = { FW_VERSIONS = {
CAR.AVALON: { CAR.AVALON: {
(Ecu.esp, 0x7b0, None): [b'F152607060\x00\x00\x00\x00\x00\x00'], (Ecu.esp, 0x7b0, None): [b'F152607060\x00\x00\x00\x00\x00\x00'],
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/test/test_car_models.py
Expand Up @@ -58,7 +58,6 @@ def get_route_log(route_name):
sys.exit(-1) sys.exit(-1)


routes = { routes = {

"975b26878285314d|2018-12-25--14-42-13": { "975b26878285314d|2018-12-25--14-42-13": {
'carFingerprint': CHRYSLER.PACIFICA_2018_HYBRID, 'carFingerprint': CHRYSLER.PACIFICA_2018_HYBRID,
'enableCamera': True, 'enableCamera': True,
Expand Down Expand Up @@ -290,6 +289,7 @@ def get_route_log(route_name):
"7e34a988419b5307|2019-12-18--19-13-30": { "7e34a988419b5307|2019-12-18--19-13-30": {
'carFingerprint': TOYOTA.RAV4H_TSS2, 'carFingerprint': TOYOTA.RAV4H_TSS2,
'enableCamera': True, 'enableCamera': True,
'fingerprintSource': 'fixed'
}, },
"e6a24be49a6cd46e|2019-10-29--10-52-42": { "e6a24be49a6cd46e|2019-10-29--10-52-42": {
'carFingerprint': TOYOTA.LEXUS_ES_TSS2, 'carFingerprint': TOYOTA.LEXUS_ES_TSS2,
Expand Down Expand Up @@ -517,6 +517,11 @@ def get_route_log(route_name):
params.put("CommunityFeaturesToggle", "1") params.put("CommunityFeaturesToggle", "1")
params.put("Passive", "1" if route in passive_routes else "0") params.put("Passive", "1" if route in passive_routes else "0")


if checks.get('fingerprintSource', None) == 'fixed':
os.environ['FINGERPRINT'] = checks['carFingerprint']
else:
os.environ['FINGERPRINT'] = ""

print("testing ", route, " ", checks['carFingerprint']) print("testing ", route, " ", checks['carFingerprint'])
print("Starting processes") print("Starting processes")
for p in tested_procs: for p in tested_procs:
Expand Down

0 comments on commit 9e6e1cb

Please sign in to comment.