can also do this!

pull/31221/head
Shane Smiskol 1 year ago
parent e7fca3ca0b
commit 1a7035612d
  1. 4
      selfdrive/car/fw_query_definitions.py
  2. 31
      selfdrive/car/fw_versions.py

@ -98,7 +98,7 @@ class FwQueryConfig:
new_request.bus += 4
self.requests.append(new_request)
def get_all_ecus(self, fw_versions: OfflineFwVersions, include_ecu: bool = False,
def get_all_ecus(self, fw_versions: OfflineFwVersions, include_ecu_type: bool = False,
include_extra_ecus: bool = True) -> set[EcuAddrSubAddr | AddrType]:
# Add ecus in database + extra ecus
brand_ecus = {ecu for ecus in fw_versions.values() for ecu in ecus}
@ -106,6 +106,6 @@ class FwQueryConfig:
if include_extra_ecus:
brand_ecus |= set(self.extra_ecus)
if include_ecu:
if include_ecu_type:
return brand_ecus
return {(addr, subaddr) for _, addr, subaddr in brand_ecus}

@ -177,22 +177,21 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[EcuAddrBusType]:
if r.bus > num_pandas * 4 - 1:
continue
for brand_versions in VERSIONS[brand].values():
for ecu_type, addr, sub_addr in list(brand_versions) + config.extra_ecus:
# Only query ecus in whitelist if whitelist is not empty
if len(r.whitelist_ecus) == 0 or ecu_type in r.whitelist_ecus:
a = (addr, sub_addr, r.bus)
# Build set of queries
if sub_addr is None:
if a not in parallel_queries[r.obd_multiplexing]:
parallel_queries[r.obd_multiplexing].append(a)
else: # subaddresses must be queried one by one
if [a] not in queries[r.obd_multiplexing]:
queries[r.obd_multiplexing].append([a])
# Build set of expected responses to filter
response_addr = uds.get_rx_addr_for_tx_addr(addr, r.rx_offset)
responses.add((response_addr, sub_addr, r.bus))
for ecu_type, addr, sub_addr in config.get_all_ecus(VERSIONS[brand], include_ecu_type=True):
# Only query ecus in whitelist if whitelist is not empty
if len(r.whitelist_ecus) == 0 or ecu_type in r.whitelist_ecus:
a = (addr, sub_addr, r.bus)
# Build set of queries
if sub_addr is None:
if a not in parallel_queries[r.obd_multiplexing]:
parallel_queries[r.obd_multiplexing].append(a)
else: # subaddresses must be queried one by one
if [a] not in queries[r.obd_multiplexing]:
queries[r.obd_multiplexing].append([a])
# Build set of expected responses to filter
response_addr = uds.get_rx_addr_for_tx_addr(addr, r.rx_offset)
responses.add((response_addr, sub_addr, r.bus))
for obd_multiplexing in queries:
queries[obd_multiplexing].insert(0, parallel_queries[obd_multiplexing])

Loading…
Cancel
Save