|
|
|
@ -206,10 +206,9 @@ def get_present_ecus_original(logcan, sendcan, num_pandas=1) -> Set[Tuple[int, O |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[Tuple[int, Optional[int], int]]: |
|
|
|
|
# TODO: batch requests by multiplexed OBD |
|
|
|
|
params = Params() |
|
|
|
|
queries = {"obd": [], "non_obd": []} # list() |
|
|
|
|
parallel_queries = {"obd": [], "non_obd": []} # list() |
|
|
|
|
queries = defaultdict(list) |
|
|
|
|
parallel_queries = defaultdict(list) |
|
|
|
|
responses = set() |
|
|
|
|
|
|
|
|
|
for brand, r in REQUESTS: |
|
|
|
@ -224,25 +223,24 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[Tuple[int, Optional[i |
|
|
|
|
a = (addr, sub_addr, r.bus) |
|
|
|
|
print((a, r.non_obd)) |
|
|
|
|
# Build set of queries |
|
|
|
|
multiplexed_key = "non_obd" if r.non_obd else "obd" |
|
|
|
|
if sub_addr is None: |
|
|
|
|
if a not in parallel_queries[multiplexed_key]: |
|
|
|
|
parallel_queries[multiplexed_key].append(a) |
|
|
|
|
if a not in parallel_queries[r.non_obd]: |
|
|
|
|
parallel_queries[r.non_obd].append(a) |
|
|
|
|
else: # subaddresses must be queried one by one |
|
|
|
|
if [a] not in queries[multiplexed_key]: |
|
|
|
|
queries[multiplexed_key].append([a]) |
|
|
|
|
if [a] not in queries[r.non_obd]: |
|
|
|
|
queries[r.non_obd].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 multiplexed_key in queries: |
|
|
|
|
queries[multiplexed_key].insert(0, parallel_queries[multiplexed_key]) |
|
|
|
|
for non_obd in queries: |
|
|
|
|
queries[non_obd].insert(0, parallel_queries[non_obd]) |
|
|
|
|
|
|
|
|
|
ecu_responses = set() |
|
|
|
|
for multiplexed_key in queries: |
|
|
|
|
set_obd_multiplexing(params, multiplexed_key == 'obd') |
|
|
|
|
for query in queries[multiplexed_key]: |
|
|
|
|
for non_obd in queries: |
|
|
|
|
set_obd_multiplexing(params, not non_obd) |
|
|
|
|
for query in queries[non_obd]: |
|
|
|
|
ecu_responses.update(get_ecu_addrs(logcan, sendcan, set(query), responses, timeout=0.1)) |
|
|
|
|
return ecu_responses |
|
|
|
|
|
|
|
|
|