examples: fix query_fw_versions.py heartbeat
#!/usr/bin/env python3
import argparse
+import _thread
from tqdm import tqdm
from panda import Panda
from panda.python.uds import UdsClient, MessageTimeoutError, NegativeResponseError, SESSION_TYPE, DATA_IDENTIFIER_TYPE
+
+def heartbeat_thread(p):
+ while True:
+ try:
+ p.send_heartbeat()
+ time.sleep(0.5)
+ except Exception:
+ continue
+
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--rxoffset', default="")
parser.add_argument('--nonstandard', action='store_true')
parser.add_argument('--debug', action='store_true')
parser.add_argument('--addr')
+ parser.add_argument('--bus')
args = parser.parse_args()
if args.addr:
@@ -32,6 +43,7 @@ if __name__ == "__main__":
panda = Panda()
panda.set_safety_mode(Panda.SAFETY_ELM327)
+ _thread.start_new_thread(heartbeat_thread, (panda,))
print("querying addresses ...")
with tqdm(addrs) as t:
for addr in t:
@@ -39,8 +51,10 @@ if __name__ == "__main__":
if addr == 0x7df or addr == 0x18db33f1:
continue
t.set_description(hex(addr))
- panda.send_heartbeat()
+ if args.bus:
+ bus = int(args.bus)
+ else:
bus = 1 if panda.has_obd() else 0
rx_addr = addr + int(args.rxoffset, base=16) if args.rxoffset else None
uds_client = UdsClient(panda, addr, rx_addr, bus, timeout=0.2, debug=args.debug)
