tools: fix up can_replay

pull/31299/head
Adeeb Shihadeh 1 year ago
parent a094179b4d
commit 3972073fd4
  1. 28
      tools/replay/can_replay.py

@ -2,6 +2,7 @@
import argparse import argparse
import os import os
import time import time
import usb1
import threading import threading
os.environ['FILEREADER_CACHE'] = '1' os.environ['FILEREADER_CACHE'] = '1'
@ -42,7 +43,11 @@ def send_thread(s, flock):
snd = CAN_MSGS[idx] snd = CAN_MSGS[idx]
snd = list(filter(lambda x: x[-1] <= 2, snd)) snd = list(filter(lambda x: x[-1] <= 2, snd))
s.can_send_many(snd) try:
s.can_send_many(snd)
except usb1.USBErrorTimeout:
# timeout is fine, just means the CAN TX buffer is full
pass
idx = (idx + 1) % len(CAN_MSGS) idx = (idx + 1) % len(CAN_MSGS)
# Drain panda message buffer # Drain panda message buffer
@ -57,20 +62,11 @@ def connect():
flashing_lock = threading.Lock() flashing_lock = threading.Lock()
while True: while True:
# look for new devices # look for new devices
for p in [Panda, PandaJungle]: for s in PandaJungle.list():
if p is None: if s not in serials:
continue print("starting send thread for", s)
serials[s] = threading.Thread(target=send_thread, args=(PandaJungle(s), flashing_lock))
for s in p.list(): serials[s].start()
if s not in serials:
with p(s) as pp:
if pp.get_type() == Panda.HW_TYPE_TRES:
serials[s] = None
continue
print("starting send thread for", s)
serials[s] = threading.Thread(target=send_thread, args=(p(s), flashing_lock))
serials[s].start()
# try to join all send threads # try to join all send threads
cur_serials = serials.copy() cur_serials = serials.copy()
@ -94,7 +90,7 @@ if __name__ == "__main__":
print("Loading log...") print("Loading log...")
if args.route_or_segment_name is None: if args.route_or_segment_name is None:
args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/10:16" args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/1:3"
sr = LogReader(args.route_or_segment_name) sr = LogReader(args.route_or_segment_name)

Loading…
Cancel
Save