當前位置: 首頁>>代碼示例>>Python>>正文


Python usb1.USBErrorBusy方法代碼示例

本文整理匯總了Python中usb1.USBErrorBusy方法的典型用法代碼示例。如果您正苦於以下問題:Python usb1.USBErrorBusy方法的具體用法?Python usb1.USBErrorBusy怎麽用?Python usb1.USBErrorBusy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在usb1的用法示例。


在下文中一共展示了usb1.USBErrorBusy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open

# 需要導入模塊: import usb1 [as 別名]
# 或者: from usb1 import USBErrorBusy [as 別名]
def open(cls):
        #pdb.set_trace()
        try:
            cls.transport = get_transport(None, prefix_search=False)
        except StopIteration as e:
           debug(); pdb.set_trace()
 
        init_msg = proto.Initialize()

        if cls.state is not None:
            init_msg.state = cls.state

        try:
            cls.features = cls.call_raw(init_msg)
            logging.info("call_raw transport.write(msg): %s", init_msg)
        except (TransportException, USBErrorBusy):
            raise OpenCredstickError("Error opening Trezor") 
開發者ID:kayagoban,項目名稱:shadowlands,代碼行數:19,代碼來源:trezor_ethdriver.py

示例2: openLink

# 需要導入模塊: import usb1 [as 別名]
# 或者: from usb1 import USBErrorBusy [as 別名]
def openLink(self, port_id, sendEndpoint, receiveEndpoint):
		if port_id is not None:
			if self._dev_handle is None:
				try:
					port_parts = port_id.split(':') #port id is "vid:pid"
					vid = int(port_parts[0])
					pid = int(port_parts[1])

					self._context = usb1.USBContext()
					self._dev_handle = self._context.openByVendorIDAndProductID(vid, pid, skip_on_error=True)
					if self._dev_handle is not None:
						self._hasError = False
						self._dev_handle.claimInterface(0)
						self._port_id = port_id
						self._sendEP = sendEndpoint
						self._receiveEP = receiveEndpoint
						#self._incomingQueue = IncomingQueue(self._eventListener)
						#self._incomingQueue.start()
						#self._linkReader = LinkReader(self._dev_handle, self._context, receiveEndpoint, self._eventListener, self._incomingQueue, self)
						self._linkReader = LinkReader(self._dev_handle, self._context, receiveEndpoint, self._eventListener, self)
						self._linkReader.start()
						self._serialLoggerEnabled and self._serialLogger.debug("Connected to USB Device -> Vendor: 0x%04x, Product: 0x%04x" % (vid, pid))
						self._eventListener.onLinkOpened()
						return True

				except usb1.USBErrorBusy:
					return False

			else:
				return True #It was already opened

		return False

	#
	# closes communication with the USB device
	# 
開發者ID:AstroPrint,項目名稱:AstroBox,代碼行數:38,代碼來源:usb_t.py

示例3: catchUsbBusy

# 需要導入模塊: import usb1 [as 別名]
# 或者: from usb1 import USBErrorBusy [as 別名]
def catchUsbBusy(fn):
    def wrapped(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except usb1.USBErrorBusy as e:
            logger.error("Could not claim USB device, got LIBUSB_ERROR_BUSY.\nIf you have a running adb server, you'll need to stop it by running 'adb kill-server' and then try again")
            sys.exit(1)

    return wrapped 
開發者ID:tgalal,項目名稱:inception,代碼行數:11,代碼來源:adbwrapper.py

示例4: wait_for_device

# 需要導入模塊: import usb1 [as 別名]
# 或者: from usb1 import USBErrorBusy [as 別名]
def wait_for_device(self):
        while State.DISCONNECTED == self.state:
            usbdev = self.find_fastboot_device()
            if None != usbdev:
                try:
                    usbdev.Open()
                    I("fastboot connected to %s", usbdev.serial_number)
                except usb1.USBError as e:
                    usbdev.Close()
                    time.sleep(5)
                    continue

                self.usbdev = usbdev
                self.set_state(State.CONNECTED_FB)
                continue

            usbdev = self.find_adb_device()
            if None != usbdev:
                try:
                    usbdev.Open()
                    I("adb: connected")
                    self.set_state(State.CONNECTED_ADB_DEVICE)

                except usb1.USBErrorBusy as e:
                    self.set_state(self.adb_get_state())
                    if State.CONNECTED_ADB_DEVICE == self.state:
                        I("adb: connected")

                except usb1.USBError:
                    usbdev.Close()
                    time.sleep(5)
                    continue

                self.usbdev = usbdev
                continue

            I("Waiting for device...")
            time.sleep(5) 
開發者ID:alephsecurity,項目名稱:abootool,代碼行數:40,代碼來源:device.py

示例5: open

# 需要導入模塊: import usb1 [as 別名]
# 或者: from usb1 import USBErrorBusy [as 別名]
def open(self, usb_bus, dev_adr):
        self.usb_dev = None
        self.usb_out = None
        self.usb_inp = None

        for dev in self.context.getDeviceList(skip_on_error=True):
            if ((dev.getBusNumber() == usb_bus and
                 dev.getDeviceAddress() == dev_adr)):
                break
        else:
            log.error("no device {0} on bus {1}".format(dev_adr, usb_bus))
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))

        try:
            first_setting = next(dev.iterSettings())
        except StopIteration:
            log.error("no usb configuration settings, please replug device")
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))

        def transfer_type(x):
            return x & libusb.TRANSFER_TYPE_MASK

        def endpoint_dir(x):
            return x & libusb.ENDPOINT_DIR_MASK

        for endpoint in first_setting.iterEndpoints():
            ep_addr = endpoint.getAddress()
            ep_attr = endpoint.getAttributes()
            if transfer_type(ep_attr) == libusb.TRANSFER_TYPE_BULK:
                if endpoint_dir(ep_addr) == libusb.ENDPOINT_IN:
                    if not self.usb_inp:
                        self.usb_inp = endpoint
                if endpoint_dir(ep_addr) == libusb.ENDPOINT_OUT:
                    if not self.usb_out:
                        self.usb_out = endpoint

        if not (self.usb_inp and self.usb_out):
            log.error("no bulk endpoints for read and write")
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))

        try:
            # workaround the PN533's buggy USB implementation
            self._manufacturer_name = dev.getManufacturer()
            self._product_name = dev.getProduct()
        except libusb.USBErrorIO:
            self._manufacturer_name = None
            self._product_name = None

        try:
            self.usb_dev = dev.open()
            self.usb_dev.claimInterface(0)
        except libusb.USBErrorAccess:
            raise IOError(errno.EACCES, os.strerror(errno.EACCES))
        except libusb.USBErrorBusy:
            raise IOError(errno.EBUSY, os.strerror(errno.EBUSY))
        except libusb.USBErrorNoDevice:
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV)) 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:59,代碼來源:transport.py


注:本文中的usb1.USBErrorBusy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。