can replay: flashing lock
old-commit-hash: 6a5940c56242374dcb6f24a521a75dce2641b1b1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
from tqdm import tqdm
|
||||
|
||||
os.environ['FILEREADER_CACHE'] = '1'
|
||||
@@ -15,16 +15,17 @@ try:
|
||||
except Exception:
|
||||
PandaJungle = None # type: ignore
|
||||
|
||||
ROUTE = "77611a1fac303767/2020-03-24--09-50-38"
|
||||
NUM_SEGS = 2 # route has 82 segments available
|
||||
|
||||
print("Loading log...")
|
||||
ROUTE = "77611a1fac303767/2020-03-24--09-50-38"
|
||||
NUM_SEGS = 2 # route has 82 segments available
|
||||
CAN_MSGS = []
|
||||
for i in tqdm(list(range(1, NUM_SEGS+1))):
|
||||
log_url = f"https://commadataci.blob.core.windows.net/openpilotci/{ROUTE}/{i}/rlog.bz2"
|
||||
lr = LogReader(log_url)
|
||||
CAN_MSGS += [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can']
|
||||
|
||||
|
||||
# set both to cycle ignition
|
||||
IGN_ON = int(os.getenv("ON", "0"))
|
||||
IGN_OFF = int(os.getenv("OFF", "0"))
|
||||
@@ -33,10 +34,11 @@ if ENABLE_IGN:
|
||||
print(f"Cycling ignition: on for {IGN_ON}s, off for {IGN_OFF}s")
|
||||
|
||||
|
||||
def send_thread(s):
|
||||
def send_thread(s, flock):
|
||||
if "Jungle" in str(type(s)):
|
||||
if "FLASH" in os.environ:
|
||||
s.flash()
|
||||
with flock:
|
||||
s.flash()
|
||||
|
||||
for i in [0, 1, 2, 3, 0xFFFF]:
|
||||
s.can_clear(i)
|
||||
@@ -48,7 +50,6 @@ def send_thread(s):
|
||||
s.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
|
||||
s.set_can_loopback(False)
|
||||
|
||||
|
||||
idx = 0
|
||||
ign = True
|
||||
rk = Ratekeeper(1 / DT_CTRL, print_delay_threshold=None)
|
||||
@@ -74,6 +75,7 @@ def connect():
|
||||
config_realtime_process(3, 55)
|
||||
|
||||
serials = {}
|
||||
flashing_lock = threading.Lock()
|
||||
while True:
|
||||
# look for new devices
|
||||
for p in [Panda, PandaJungle]:
|
||||
@@ -83,14 +85,14 @@ def connect():
|
||||
for s in p.list():
|
||||
if s not in serials:
|
||||
print("starting send thread for", s)
|
||||
serials[s] = Process(target=send_thread, args=(p(s), ))
|
||||
serials[s] = threading.Thread(target=send_thread, args=(p(s), flashing_lock))
|
||||
serials[s].start()
|
||||
|
||||
# try to join all send procs
|
||||
# try to join all send threads
|
||||
cur_serials = serials.copy()
|
||||
for s, p in cur_serials.items():
|
||||
p.join(0.01)
|
||||
if p.exitcode is not None:
|
||||
for s, t in cur_serials.items():
|
||||
t.join(0.01)
|
||||
if not t.is_alive():
|
||||
del serials[s]
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user