forked from commaai/panda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_reset_hw.py
executable file
·40 lines (31 loc) · 1.02 KB
/
ci_reset_hw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import concurrent.futures
from panda import Panda, PandaDFU
from panda.tests.libs.resetter import Resetter
# Reset + flash all CI hardware to get it into a consistent state
# * ports 1-2 are jungles
# * port 3 is for the USB hubs
if __name__ == "__main__":
r = Resetter()
r.enable_boot(True)
r.cycle_power(delay=7, ports=[1, 2, 3])
r.enable_boot(False)
pandas = PandaDFU.list()
print("DFU pandas:", pandas)
assert len(pandas) == 7
with concurrent.futures.ProcessPoolExecutor(max_workers=len(pandas)) as exc:
def recover(serial):
PandaDFU(serial).recover()
list(exc.map(recover, pandas, timeout=20))
r.cycle_power(delay=7, ports=[1, 2])
pandas = Panda.list()
print(pandas)
assert len(pandas) == 7
with concurrent.futures.ProcessPoolExecutor(max_workers=len(pandas)) as exc:
def flash(serial):
with Panda(serial) as pf:
if pf.bootstub:
pf.flash()
list(exc.map(flash, pandas, timeout=20))
r.cycle_power(delay=0, ports=[1, 2])
r.close()