mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
python: add helper to wait until panda comes up (#1447)
Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -536,6 +536,18 @@ class Panda:
|
||||
dfu_list = PandaDFU.list()
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def wait_for_panda(serial: Optional[str], timeout: int) -> bool:
|
||||
t_start = time.monotonic()
|
||||
serials = Panda.list()
|
||||
while (serial is None and len(serials) == 0) or (serial is not None and serial not in serials):
|
||||
logging.debug("waiting for panda...")
|
||||
time.sleep(0.1)
|
||||
if timeout is not None and (time.monotonic() - t_start) > timeout:
|
||||
return False
|
||||
serials = Panda.list()
|
||||
return True
|
||||
|
||||
def up_to_date(self) -> bool:
|
||||
current = self.get_signature()
|
||||
fn = os.path.join(FW_PATH, self.get_mcu_type().config.app_fn)
|
||||
|
||||
Reference in New Issue
Block a user