def recover(self): self.reset(enter_bootloader=True) while len(PandaDFU.list()) == 0: print("waiting for DFU...") time.sleep(0.1) dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial)) dfu.recover() # reflash after recover self.connect(True, True) self.flash()
def recover(self, timeout=None): self.reset(enter_bootloader=True) t_start = time.time() while len(PandaDFU.list()) == 0: print("waiting for DFU...") time.sleep(0.1) if timeout is not None and (time.time() - t_start) > timeout: return False dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial)) dfu.recover() # reflash after recover self.connect(True, True) self.flash() return True