FPv2: log responses from data collection queries (#27345)

* log responses from logging/debugging queries

* don't add logging FW to FW dict for fingerprinting

* flip?

* fine before

* log if extra in debug ecus

* clean up

* test extra ecus too

* Revert "test extra ecus too"

This reverts commit 8f7867844d.

* bump to master
pull/27180/head
Shane Smiskol 2 years ago committed by GitHub
parent e49748d571
commit f29e19cf42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cereal
  2. 2
      selfdrive/car/fw_query_definitions.py
  3. 17
      selfdrive/car/fw_versions.py
  4. 2
      selfdrive/car/honda/values.py

@ -1 +1 @@
Subproject commit fa3e77b7c8eee8752f19427b34adcb1ae5c70ec5 Subproject commit 162a26ca2d7e5bc9a42bb5ea11e98194f722027b

@ -57,6 +57,8 @@ class Request:
whitelist_ecus: List[int] = field(default_factory=list) whitelist_ecus: List[int] = field(default_factory=list)
rx_offset: int = 0x8 rx_offset: int = 0x8
bus: int = 1 bus: int = 1
# FW responses from these queries will not be used for fingerprinting
logging: bool = False
@dataclass @dataclass

@ -29,10 +29,9 @@ def chunks(l, n=128):
def build_fw_dict(fw_versions, filter_brand=None): def build_fw_dict(fw_versions, filter_brand=None):
fw_versions_dict = defaultdict(set) fw_versions_dict = defaultdict(set)
for fw in fw_versions: for fw in fw_versions:
if filter_brand is None or fw.brand == filter_brand: if (filter_brand is None or fw.brand == filter_brand) and not fw.logging:
addr = fw.address
sub_addr = fw.subAddress if fw.subAddress != 0 else None sub_addr = fw.subAddress if fw.subAddress != 0 else None
fw_versions_dict[(addr, sub_addr)].add(fw.fwVersion) fw_versions_dict[(fw.address, sub_addr)].add(fw.fwVersion)
return dict(fw_versions_dict) return dict(fw_versions_dict)
@ -232,15 +231,19 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1,
# ECUs using a subaddress need be queried one by one, the rest can be done in parallel # ECUs using a subaddress need be queried one by one, the rest can be done in parallel
addrs = [] addrs = []
parallel_addrs = [] parallel_addrs = []
logging_addrs = []
ecu_types = {} ecu_types = {}
for brand, brand_versions in versions.items(): for brand, brand_versions in versions.items():
for c in brand_versions.values(): for candidate, ecu in brand_versions.items():
for ecu_type, addr, sub_addr in c.keys(): for ecu_type, addr, sub_addr in ecu.keys():
a = (brand, addr, sub_addr) a = (brand, addr, sub_addr)
if a not in ecu_types: if a not in ecu_types:
ecu_types[a] = ecu_type ecu_types[a] = ecu_type
if a not in logging_addrs and candidate == "debug":
logging_addrs.append(a)
if sub_addr is None: if sub_addr is None:
if a not in parallel_addrs: if a not in parallel_addrs:
parallel_addrs.append(a) parallel_addrs.append(a)
@ -269,13 +272,15 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1,
for (tx_addr, sub_addr), version in query.get_data(timeout).items(): for (tx_addr, sub_addr), version in query.get_data(timeout).items():
f = car.CarParams.CarFw.new_message() f = car.CarParams.CarFw.new_message()
f.ecu = ecu_types.get((brand, tx_addr, sub_addr), Ecu.unknown) ecu_key = (brand, tx_addr, sub_addr)
f.ecu = ecu_types.get(ecu_key, Ecu.unknown)
f.fwVersion = version f.fwVersion = version
f.address = tx_addr f.address = tx_addr
f.responseAddress = uds.get_rx_addr_for_tx_addr(tx_addr, r.rx_offset) f.responseAddress = uds.get_rx_addr_for_tx_addr(tx_addr, r.rx_offset)
f.request = r.request f.request = r.request
f.brand = brand f.brand = brand
f.bus = r.bus f.bus = r.bus
f.logging = r.logging or ecu_key in logging_addrs
if sub_addr is not None: if sub_addr is not None:
f.subAddress = sub_addr f.subAddress = sub_addr

@ -171,12 +171,14 @@ FW_QUERY_CONFIG = FwQueryConfig(
[HONDA_VERSION_REQUEST], [HONDA_VERSION_REQUEST],
[HONDA_VERSION_RESPONSE], [HONDA_VERSION_RESPONSE],
bus=1, bus=1,
logging=True
), ),
# Query Nidec PT bus from camera for data collection # Query Nidec PT bus from camera for data collection
Request( Request(
[StdQueries.UDS_VERSION_REQUEST], [StdQueries.UDS_VERSION_REQUEST],
[StdQueries.UDS_VERSION_RESPONSE], [StdQueries.UDS_VERSION_RESPONSE],
bus=0, bus=0,
logging=True
), ),
], ],
extra_ecus=[ extra_ecus=[

Loading…
Cancel
Save