mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
CI: faster and more reliable HW reset (#1220)
* CI: faster and more reliable HW reset * little more speed * cleanup Co-authored-by: Bruce Wayne <batman@comma.ai>
This commit is contained in:
34
tests/ci_reset_hw.py
Normal file → Executable file
34
tests/ci_reset_hw.py
Normal file → Executable file
@@ -1,34 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
import concurrent.futures
|
||||
|
||||
from panda import Panda, PandaDFU
|
||||
from panda.tests.libs.resetter import Resetter
|
||||
|
||||
|
||||
# resets power for both jungles(ports 1 and 2) and USB hubs(port 3)
|
||||
# puts pandas into DFU mode and flashes bootstub + app
|
||||
# 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=5, ports=[1,2,3])
|
||||
r.cycle_power(delay=7, ports=[1, 2, 3])
|
||||
r.enable_boot(False)
|
||||
|
||||
pandas = PandaDFU.list()
|
||||
print(pandas)
|
||||
print("DFU pandas:", pandas)
|
||||
assert len(pandas) == 8
|
||||
|
||||
for serial in pandas:
|
||||
p = PandaDFU(serial)
|
||||
p.recover()
|
||||
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=5, ports=[1,2])
|
||||
r.cycle_power(delay=3, ports=[1, 2])
|
||||
|
||||
pandas = Panda.list()
|
||||
print(pandas)
|
||||
assert len(pandas) == 8
|
||||
|
||||
for serial in pandas:
|
||||
with Panda(serial) as pf:
|
||||
if pf.bootstub:
|
||||
pf.flash()
|
||||
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.cycle_power(delay=0, ports=[1, 2])
|
||||
r.close()
|
||||
|
||||
@@ -44,11 +44,14 @@ class Resetter():
|
||||
|
||||
def cycle_power(self, delay=5, ports=None):
|
||||
if ports is None:
|
||||
ports = [1,2,3]
|
||||
ports = [1, 2, 3]
|
||||
|
||||
for port in ports:
|
||||
self.enable_power(port, False)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
for port in ports:
|
||||
self.enable_power(port, True)
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
||||
|
||||
time.sleep(delay)
|
||||
|
||||
Reference in New Issue
Block a user