python: wait on any DFU panda (#1435)

This commit is contained in:
Adeeb Shihadeh
2023-05-23 20:50:09 -07:00
committed by GitHub
parent 2a5058d858
commit 2da9b8d173

View File

@@ -525,13 +525,15 @@ class Panda:
return True
@staticmethod
def wait_for_dfu(dfu_serial: str, timeout: Optional[int] = None) -> bool:
def wait_for_dfu(dfu_serial: Optional[str], timeout: Optional[int] = None) -> bool:
t_start = time.monotonic()
while dfu_serial not in PandaDFU.list():
dfu_list = PandaDFU.list()
while (dfu_serial is None and len(dfu_list) == 0) or (dfu_serial is not None and dfu_serial not in dfu_list):
logging.debug("waiting for DFU...")
time.sleep(0.1)
if timeout is not None and (time.monotonic() - t_start) > timeout:
return False
dfu_list = PandaDFU.list()
return True
def up_to_date(self) -> bool: