diff --git a/examples/query_fw_versions.py b/examples/query_fw_versions.py index c6704f0d4..934bd716b 100755 --- a/examples/query_fw_versions.py +++ b/examples/query_fw_versions.py @@ -9,63 +9,68 @@ if __name__ == "__main__": results = {} panda = Panda() - panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + panda.set_safety_mode(Panda.SAFETY_ELM327) print("querying addresses ...") - for addr in tqdm(addrs): - # skip functional broadcast addrs - if addr == 0x7df or addr == 0x18db33f1: - continue + with tqdm(addrs) as t: + for addr in t: + # skip functional broadcast addrs + if addr == 0x7df or addr == 0x18db33f1: + continue + t.set_description(hex(addr)) - uds_client = UdsClient(panda, addr, bus=1 if panda.has_obd() else 0, timeout=0.1, debug=False) - try: - uds_client.tester_present() - except NegativeResponseError: - pass - except MessageTimeoutError: - continue + uds_client = UdsClient(panda, addr, bus=1 if panda.has_obd() else 0, timeout=0.1, debug=False) + try: + uds_client.tester_present() + except NegativeResponseError: + pass + except MessageTimeoutError: + continue - resp = {} + resp = {} - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_IDENTIFICATION) - if data: resp[DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_IDENTIFICATION] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_IDENTIFICATION) + if data: resp[DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_IDENTIFICATION] = data + except NegativeResponseError: + pass - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) - if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) + if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION] = data + except NegativeResponseError: + pass - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION) - if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION) + if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION] = data + except NegativeResponseError: + pass - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_FINGERPRINT) - if data: resp[DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_FINGERPRINT] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_FINGERPRINT) + if data: resp[DATA_IDENTIFIER_TYPE.BOOT_SOFTWARE_FINGERPRINT] = data + except NegativeResponseError: + pass - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_FINGERPRINT) - if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_FINGERPRINT] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_FINGERPRINT) + if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_FINGERPRINT] = data + except NegativeResponseError: + pass - try: - data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_DATA_FINGERPRINT) - if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_DATA_FINGERPRINT] = data - except NegativeResponseError: - pass + try: + data = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.APPLICATION_DATA_FINGERPRINT) + if data: resp[DATA_IDENTIFIER_TYPE.APPLICATION_DATA_FINGERPRINT] = data + except NegativeResponseError: + pass - if resp.keys(): - results[addr] = resp + if resp.keys(): + results[addr] = resp - print("results:") - for addr, resp in results.items(): - for id, dat in resp.items(): - print(hex(addr), hex(id), dat.decode()) + print("results:") + if len(results.items()): + for addr, resp in results.items(): + for id, dat in resp.items(): + print(hex(addr), hex(id), dat.decode()) + else: + "no fw versions found!" diff --git a/python/uds.py b/python/uds.py index 190796bb6..ee9e9ea66 100644 --- a/python/uds.py +++ b/python/uds.py @@ -436,7 +436,12 @@ class IsoTpMessage(): # wait (do nothing until next flow control message) if self.debug: print("ISO-TP: TX - flow control wait") +FUNCTIONAL_ADDRS = [0x7DF, 0x18DB33F1] + def get_rx_addr_for_tx_addr(tx_addr): + if tx_addr in FUNCTIONAL_ADDRS: + return None + if tx_addr < 0xFFF8: # standard 11 bit response addr (add 8) return tx_addr + 8