def task_init(self, state): openmv.disconnect() try: # Attempt to connect to bootloader openmv.init(self.port, baudrate=self.baud, timeout=0.050) if openmv.bootloader_start(): openmv.set_timeout(1) state["next"] = self.task_erase state["bar"].set_text("Erasing...") self.cancel_button.set_sensitive(False) except Exception as e: openmv.disconnect() if self.flash_msg: state["bar"].set_text("Connecting to bootloader...\ \n ") else: state["bar"].set_text("Connecting to bootloader...\ \nDisconnect and re-connect cam!") self.flash_msg = self.flash_msg ^ 1 sleep(0.100) return True