mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
Only send FW query requests for the right brand (#1546)
* only send requests for the right brand * this works on sonata Co-authored-by: openpilot laptop <laptop@comma.ai> old-commit-hash: 1162041ea63a7213b9e2b9c11edd521c89f86c99
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
||||
from common.basedir import BASEDIR
|
||||
|
||||
|
||||
def get_attr_from_cars(attr, result=dict):
|
||||
def get_attr_from_cars(attr, result=dict, combine_brands=True):
|
||||
# read all the folders in selfdrive/car and return a dict where:
|
||||
# - keys are all the car models
|
||||
# - values are attr values from all car folders
|
||||
@@ -19,7 +19,12 @@ def get_attr_from_cars(attr, result=dict):
|
||||
|
||||
if isinstance(attr_values, dict):
|
||||
for f, v in attr_values.items():
|
||||
result[f] = v
|
||||
if combine_brands:
|
||||
result[f] = v
|
||||
else:
|
||||
if car_name not in result:
|
||||
result[car_name] = {}
|
||||
result[car_name][f] = v
|
||||
elif isinstance(attr_values, list):
|
||||
result += attr_values
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from tqdm import tqdm
|
||||
|
||||
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
|
||||
from selfdrive.swaglog import cloudlog
|
||||
from selfdrive.car.fingerprints import FW_VERSIONS
|
||||
from selfdrive.car.fingerprints import get_attr_from_cars, FW_VERSIONS
|
||||
from selfdrive.car.toyota.values import CAR as TOYOTA
|
||||
import panda.python.uds as uds
|
||||
|
||||
@@ -56,29 +56,29 @@ OBD_VERSION_RESPONSE = b'\x49\x04'
|
||||
REQUESTS = [
|
||||
# Hundai
|
||||
(
|
||||
False,
|
||||
"hyundai",
|
||||
[HYUNDAI_VERSION_REQUEST],
|
||||
[HYUNDAI_VERSION_RESPONSE],
|
||||
),
|
||||
# Honda
|
||||
(
|
||||
False,
|
||||
"honda",
|
||||
[UDS_VERSION_REQUEST],
|
||||
[UDS_VERSION_RESPONSE],
|
||||
),
|
||||
# Toyota
|
||||
(
|
||||
True,
|
||||
"toyota",
|
||||
[SHORT_TESTER_PRESENT_REQUEST, TOYOTA_VERSION_REQUEST],
|
||||
[SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE],
|
||||
),
|
||||
(
|
||||
True,
|
||||
"toyota",
|
||||
[SHORT_TESTER_PRESENT_REQUEST, OBD_VERSION_REQUEST],
|
||||
[SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE],
|
||||
),
|
||||
(
|
||||
True,
|
||||
"toyota",
|
||||
[TESTER_PRESENT_REQUEST, DEFAULT_DIAGNOSTIC_REQUEST, EXTENDED_DIAGNOSTIC_REQUEST, UDS_VERSION_REQUEST],
|
||||
[TESTER_PRESENT_RESPONSE, DEFAULT_DIAGNOSTIC_RESPONSE, EXTENDED_DIAGNOSTIC_RESPONSE, UDS_VERSION_RESPONSE],
|
||||
)
|
||||
@@ -132,37 +132,37 @@ def get_fw_versions(logcan, sendcan, bus, extra=None, timeout=0.1, debug=False,
|
||||
addrs = []
|
||||
parallel_addrs = []
|
||||
|
||||
versions = FW_VERSIONS
|
||||
versions = get_attr_from_cars('FW_VERSIONS', combine_brands=False)
|
||||
if extra is not None:
|
||||
versions.update(extra)
|
||||
|
||||
for c in versions.values():
|
||||
for ecu_type, addr, sub_addr in c.keys():
|
||||
a = (addr, sub_addr)
|
||||
if a not in ecu_types:
|
||||
ecu_types[a] = ecu_type
|
||||
for brand, brand_versions in versions.items():
|
||||
for c in brand_versions.values():
|
||||
for ecu_type, addr, sub_addr in c.keys():
|
||||
a = (brand, addr, sub_addr)
|
||||
if a not in ecu_types:
|
||||
ecu_types[(addr, sub_addr)] = ecu_type
|
||||
|
||||
if sub_addr is None:
|
||||
if a not in parallel_addrs:
|
||||
parallel_addrs.append(a)
|
||||
else:
|
||||
if [a] not in addrs:
|
||||
addrs.append([a])
|
||||
if sub_addr is None:
|
||||
if a not in parallel_addrs:
|
||||
parallel_addrs.append(a)
|
||||
else:
|
||||
if [a] not in addrs:
|
||||
addrs.append([a])
|
||||
|
||||
addrs.insert(0, parallel_addrs)
|
||||
|
||||
fw_versions = {}
|
||||
for i, addr in enumerate(tqdm(addrs, disable=not progress)):
|
||||
for addr_chunk in chunks(addr):
|
||||
for supports_sub_addr, request, response in REQUESTS:
|
||||
for brand, request, response in REQUESTS:
|
||||
try:
|
||||
# Don't send Hyundai and Honda requests to subaddress
|
||||
if i != 0 and not supports_sub_addr:
|
||||
continue
|
||||
addrs = [(a, s) for (b, a, s) in addr_chunk if b in (brand, 'any')]
|
||||
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, addr_chunk, request, response, debug=debug)
|
||||
t = 2 * timeout if i == 0 else timeout
|
||||
fw_versions.update(query.get_data(t))
|
||||
if addrs:
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, addrs, request, response, debug=debug)
|
||||
t = 2 * timeout if i == 0 else timeout
|
||||
fw_versions.update(query.get_data(t))
|
||||
except Exception:
|
||||
cloudlog.warning(f"FW query exception: {traceback.format_exc()}")
|
||||
|
||||
@@ -199,12 +199,13 @@ if __name__ == "__main__":
|
||||
|
||||
extra = None
|
||||
if args.scan:
|
||||
extra = {"DEBUG": {}}
|
||||
extra = {}
|
||||
# Honda
|
||||
for i in range(256):
|
||||
extra["DEBUG"][(Ecu.unknown, 0x18da00f1 + (i << 8), None)] = []
|
||||
extra["DEBUG"][(Ecu.unknown, 0x700 + i, None)] = []
|
||||
extra["DEBUG"][(Ecu.unknown, 0x750, i)] = []
|
||||
extra[(Ecu.unknown, 0x18da00f1 + (i << 8), None)] = []
|
||||
extra[(Ecu.unknown, 0x700 + i, None)] = []
|
||||
extra[(Ecu.unknown, 0x750, i)] = []
|
||||
extra = {"any": {"debug": extra}}
|
||||
|
||||
time.sleep(1.)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ FINGERPRINTS = {
|
||||
64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1186: 2, 1191: 2, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 1952: 8, 1960: 8, 1988: 8, 1996: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8
|
||||
},
|
||||
{
|
||||
64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 6, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1268: 8, 1280: 1, 1281: 3, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1491: 8, 1492: 8
|
||||
64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 6, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1268: 8, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1491: 8, 1492: 8
|
||||
},
|
||||
],
|
||||
CAR.KIA_SORENTO: [{
|
||||
@@ -141,7 +141,7 @@ FW_VERSIONS = {
|
||||
(Ecu.engine, 0x7e0, None): [b'\xf1\x87391162M003\xf1\xa0000F'],
|
||||
(Ecu.eps, 0x7d4, None): [b'\xf1\x8756310L0010\x00\xf1\xa01.01'],
|
||||
(Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x8799110L0000\xf1\xa01.00'],
|
||||
(Ecu.transmission, 0x7e1, None): [b'U903\x00\x00\x00\x00\x00\x00'],
|
||||
(Ecu.transmission, 0x7e1, None): [b'\xf1\x87SALFBA4195874GJ2EVugvf\x86hgwvwww\x87wgw\x86wc_\xfb\xff\x98\x88\x8f\xff\xe23\xf1\x81U903\x00\x00\x00\x00\x00\x00'],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user