Beispiel #1
0
	def make_idle(self):
		retries = 3
		while retries:
			try:
				status = self.get_status()
			except:
				self.clear_status()
				continue

			retries -= 1

			if status.bState == STATE_DFU_IDLE:
				return True

			if ((status.bState == STATE_DFU_DOWNLOAD_SYNC) or
			    (status.bState == STATE_DFU_DOWNLOAD_IDLE) or
			    (status.bState == STATE_DFU_MANIFEST_SYNC) or
			    (status.bState == STATE_DFU_UPLOAD_IDLE) or
			    (status.bState == STATE_DFU_DOWNLOAD_BUSY) or
			    (status.bState == STATE_DFU_MANIFEST)):
				self.abort()
				continue

			if status.bState == STATE_DFU_ERROR:
				self.clear_status()
				continue

			if status.bState == STATE_APP_IDLE:
				self.detach(DFU_DETACH_TIMEOUT)
				continue

			if ((status.bState == STATE_APP_DETACH) or
			    (status.bState == STATE_DFU_MANIFEST_WAIT_RESET)):
				usb.reset(self.handle)
				return False

		raise Exception
Beispiel #2
0
    def make_idle(self):
        retries = 3
        while retries:
            try:
                status = self.get_status()
            except:
                self.clear_status()
                continue

            retries -= 1

            if status.bState == STATE_DFU_IDLE:
                return True

            if ((status.bState == STATE_DFU_DOWNLOAD_SYNC) or
                (status.bState == STATE_DFU_DOWNLOAD_IDLE) or
                (status.bState == STATE_DFU_MANIFEST_SYNC) or
                (status.bState == STATE_DFU_UPLOAD_IDLE) or
                (status.bState == STATE_DFU_DOWNLOAD_BUSY) or
                (status.bState == STATE_DFU_MANIFEST)):
                self.abort()
                continue

            if status.bState == STATE_DFU_ERROR:
                self.clear_status()
                continue

            if status.bState == STATE_APP_IDLE:
                self.detach(DFU_DETACH_TIMEOUT)
                continue

            if ((status.bState == STATE_APP_DETACH) or
                (status.bState == STATE_DFU_MANIFEST_WAIT_RESET)):
                usb.reset(self.handle)
                return False

        raise Exception