mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-27 04:53:44 +08:00
编辑pandad.py
This commit is contained in:
@@ -79,19 +79,32 @@ def main() -> None:
|
||||
while not do_exit:
|
||||
try:
|
||||
cloudlog.event("pandad.flash_and_connect", count=count)
|
||||
if (count % 2) == 0:
|
||||
if count == 0:
|
||||
HARDWARE.reset_internal_panda()
|
||||
else:
|
||||
HARDWARE.recover_internal_panda()
|
||||
count += 1
|
||||
|
||||
# Flash all Pandas in DFU mode
|
||||
for serial in PandaDFU.list():
|
||||
cloudlog.info(f"Panda in DFU mode found, flashing recovery {serial}")
|
||||
PandaDFU(serial).recover()
|
||||
time.sleep(1)
|
||||
# The internal panda takes a few seconds to boot its app after a reset.
|
||||
# Wait for it to come back in normal mode before deciding to flash.
|
||||
panda_serials: list[str] = []
|
||||
for _ in range(16):
|
||||
panda_serials = Panda.list()
|
||||
if len(panda_serials) == 1:
|
||||
try:
|
||||
with Panda(panda_serials[0]) as p:
|
||||
if not p.bootstub:
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
|
||||
if len(panda_serials) == 0:
|
||||
# Flash all Pandas in DFU mode
|
||||
for serial in PandaDFU.list():
|
||||
cloudlog.info(f"Panda in DFU mode found, flashing recovery {serial}")
|
||||
PandaDFU(serial).recover()
|
||||
time.sleep(1)
|
||||
panda_serials = Panda.list()
|
||||
|
||||
panda_serials = Panda.list()
|
||||
if len(panda_serials):
|
||||
assert len(panda_serials) == 1
|
||||
cloudlog.info(f"{len(panda_serials)} panda found, connecting - {panda_serials}")
|
||||
|
||||
Reference in New Issue
Block a user