• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python usb.busses函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中usb.busses函数的典型用法代码示例。如果您正苦于以下问题:Python busses函数的具体用法?Python busses怎么用?Python busses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了busses函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self,skipNIAs):
     self.VENDOR_ID = 0x1234 #: Vendor Id
     self.PRODUCT_ID = 0x0000 #: Product Id for the bridged usb cable
     self.TIME_OUT = 100
     self.handle = None
     self.device = None
     buses = usb.busses()
     found = False
     for bus in buses :
         for device in bus.devices :
             if device.idVendor == self.VENDOR_ID and device.idProduct == self.PRODUCT_ID:
                 if skipNIAs ==0:
                     self.device = device 
                     self.config = self.device.configurations[0]
                     self.interface = self.config.interfaces[0][0]
                     self.ENDPOINT1 = self.interface.endpoints[0].address
                     self.ENDPOINT2 = self.interface.endpoints[1].address
                     self.PACKET_LENGTH1 = self.interface.endpoints[0].maxPacketSize
                     self.PACKET_LENGTH2 = self.interface.endpoints[1].maxPacketSize
                     found = True
                     break
                 else:
                     skipNIAs -= 1
         if found:
             break
开发者ID:dror-g,项目名称:nn-colletion,代码行数:25,代码来源:InputManager.py


示例2: get_device

 def get_device(self):
     for bus in usb.busses():
         for device in bus.devices:
             if (device.idVendor == self.VENDOR_ID and
                 device.idProduct in self.POSSIBLE_PRODUCTS):
                 return device
     raise NoBuddyFound
开发者ID:agonzalezro,项目名称:cibuddy,代码行数:7,代码来源:cibuddy.py


示例3: devices

    def devices(vendor_id=None, product_id=None):
        usb_devices = [d for b in usb.busses() for d in b.devices
                       if d.deviceClass == USB_CLASS_PER_INTERFACE
                       and d.idVendor == vendor_id
                       and d.idProduct == product_id]

        return [HIDDevice(u) for u in usb_devices]
开发者ID:markllama,项目名称:powerusb,代码行数:7,代码来源:hidapi.py


示例4: search_usb

def search_usb(device):
    '''
    Takes either None, specifying that any USB device in the
    global vendor and product lists are acceptable, or takes
    a string that identifies a device in the format
    <BusNumber>:<DeviceNumber>, and returns the pyUSB objects
    for bus and device that correspond to the identifier string.
    '''
    if device == None:
        busNum = None
        devNum = None
    else:
        if ':' not in device:
            raise KBInterfaceError("USB device format expects <BusNumber>:<DeviceNumber>, but got {0} instead.".format(device))
        busNum, devNum = map(int, device.split(':', 1))
    if USBVER == 0:
        busses = usb.busses()
        for bus in busses:
            dev = search_usb_bus_v0x(bus, busNum, devNum)
            if dev != None:
                return (bus, dev)
        return None #Note, can't expect a tuple returned
    elif USBVER == 1:
        return usb.core.find(custom_match=findFromListAndBusDevId(busNum, devNum, usbVendorList, usbProductList)) #backend=backend, 
    else:
        raise Exception("USB version expected to be 0.x or 1.x.")
开发者ID:JonathonReinhart,项目名称:killerbee,代码行数:26,代码来源:kbutils.py


示例5: find_sixaxes

def find_sixaxes():
  res = []
  for bus in usb.busses():
    for dev in bus.devices:
      if dev.idVendor == vendor and dev.idProduct == product:
        res.append(dev)
  return res
开发者ID:68foxboris,项目名称:xbmc,代码行数:7,代码来源:sixpair.py


示例6: get_device

 def get_device(self) :
     buses = usb.busses()
     for bus in buses :
         for device in bus.devices :
             if device.idVendor == self.idVendor and device.idProduct == self.idProduct :
                     return device
     return None
开发者ID:ermandoser,项目名称:python-escpos,代码行数:7,代码来源:escpos.py


示例7: is_available

 def is_available():
     for bus in usb.busses():
         for device in bus.devices:
             if (device.idVendor == ID_VENDOR_GTEC and
                 device.idProduct == ID_PRODUCT_GUSB_AMP):
                 return True
     return False
开发者ID:mishugana,项目名称:mushu,代码行数:7,代码来源:gtec.py


示例8: __init__

 def __init__(self):
     self.dh = None
     footswitch = None
     self.iface = None
     self.location = None
     for bus in usb.busses():
         for dev in bus.devices:
             if dev.idVendor == VENDOR_ID and dev.idProduct == PRODUCT_ID:
                 footswitch = dev
                 self.location = (bus.dirname, dev.filename)
                 break
     if footswitch is None:
         raise BackendError("Device not found")
     for intf in footswitch.configurations[0].interfaces:
         if intf[0].interfaceNumber == INTERFACE_NUMBER:
             self.iface = intf
     self.dh = footswitch.open()
     # TODO: flaky after an ACPI suspend
     self.dh.reset()
     # This sometimes fails, and then errno doesn't get reset
     # so subsequent errors are still populated with this.
     try:
         self.dh.detachKernelDriver(self.iface[0])
     except usb.USBError as e:
         if 'Operation not permitted' in e.message:
             raise BackendError("Permission denied while removing kernel driver")
     self.dh.claimInterface(self.iface[0])
开发者ID:jdreed,项目名称:usbpedal,代码行数:27,代码来源:libusb0.py


示例9: find_device

def find_device(vendor, product):
    for bus in usb.busses():
        for device in bus.devices:
            if device.idVendor == vendor \
                    and device.idProduct == product:
                        return device
    return None
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:7,代码来源:huaweiAktBbo.py


示例10: JobTask

	def JobTask(self):
		LinkState = 0
		if fileExists('/sys/class/net/wlan0/operstate'):
			LinkState = open('/sys/class/net/wlan0/operstate').read()
			if LinkState != 'down':
				LinkState = open('/sys/class/net/wlan0/operstate').read()
		elif fileExists('/sys/class/net/eth0/operstate'):
			LinkState = open('/sys/class/net/eth0/operstate').read()
			if LinkState != 'down':
				LinkState = open('/sys/class/net/eth0/carrier').read()
		LinkState = LinkState[:1]
		if fileExists("/proc/stb/lcd/symbol_network") and config.lcd.mode.value == '1':
			open("/proc/stb/lcd/symbol_network", "w").write(str(LinkState))
		elif fileExists("/proc/stb/lcd/symbol_network") and config.lcd.mode.value == '0':
			open("/proc/stb/lcd/symbol_network", "w").write('0')

		USBState = 0
		busses = usb.busses()
		for bus in busses:
			devices = bus.devices
			for dev in devices:
				if dev.deviceClass != 9 and dev.deviceClass != 2 and dev.idVendor > 0:
# 						print ' '
# 						print "Device:", dev.filename
# 						print "  Number:", dev.deviceClass
# 						print "  idVendor: %d (0x%04x)" % (dev.idVendor, dev.idVendor)
# 						print "  idProduct: %d (0x%04x)" % (dev.idProduct, dev.idProduct)
					USBState = 1
		if fileExists("/proc/stb/lcd/symbol_usb") and config.lcd.mode.value == '1':
			open("/proc/stb/lcd/symbol_usb", "w").write(str(USBState))
		elif fileExists("/proc/stb/lcd/symbol_usb") and config.lcd.mode.value == '0':
			open("/proc/stb/lcd/symbol_usb", "w").write('0')

		self.timer.startLongTimer(30)
开发者ID:bally12345,项目名称:enigma2,代码行数:34,代码来源:Lcd.py


示例11: _findDevice

 def _findDevice(self):
     """Find the vendor and product ID on the USB bus."""
     for bus in usb.busses():
         for dev in bus.devices:
             if dev.idVendor == self.vendor_id and dev.idProduct == self.product_id:
                 return dev
     return None
开发者ID:hoevenvd,项目名称:weewx_poller,代码行数:7,代码来源:fousb.py


示例12: find_keyboard_device

def find_keyboard_device():
    for bus in usb.busses():
        for device in bus.devices:
	    print device
            if device.idVendor == USB_VENDOR and \
               device.idProduct == USB_PRODUCT or device.idProduct == USB_OTHER_PRODUCT:
                return device
开发者ID:geekdenz,项目名称:linux-scripts,代码行数:7,代码来源:blackwidow_enable.py


示例13: find_usb_devices

def find_usb_devices():
    busses = usb.busses()

    devobjs = []
    for dev in usb.core.find(find_all=True):
        serialno = None
        if dev.iSerialNumber > 0:
            try:
                serialno = dev.serial_number
            except usb.USBError:
                pass
            except ValueError:
                pass

        did = None
        try:
            did = '%04x' % dev.bcdDevice
        except TypeError:
            pass

        devobjs.append(
            LibDevice(
                vid=dev.idVendor,
                pid=dev.idProduct,
                did=did,
                serialno=serialno,
                path=Path(
                    bus=dev.bus,
                    address=dev.address)))
    return devobjs
开发者ID:CarlFK,项目名称:HDMI2USB-mode-switch,代码行数:30,代码来源:libusb.py


示例14: init

def init(n=0): #opens the device, returns its deviceHandle
	import usb
	#global dh
	b=usb.busses()
	d=b[0].devices[n]
	print "DEVICE ",n,": PID:", d.idProduct ," VID: ",d.idVendor,", devnum: ",d.devnum
	dh=d.open()
	print "manuf:",dh.getString(d.iManufacturer,1000),", SN:",dh.getString(d.iSerialNumber,1000)
	c=d.configurations[0]
	try:
		print "config:",c.value,",",dh.getString(c.iConfiguration,1000)
	except:
		pass
	ifs=c.interfaces
	i=ifs[0][0]
	es=i.endpoints
	for e in es:
		if e.address>=128:
			ei=e.address
		else:
			eo=e.address
	dh.setConfiguration(c)
	global dhG
	try:
		dh.claimInterface(i)
		dhG=dh
	except usb.USBError:
		print "					INTERFACE WAS BUSY; RELEASING..."
		dhG.releaseInterface()
		#dh.releaseInterface()
		dh.claimInterface(i)
		dhG=dh
	return {"hnd":dh,"in":ei,"out":eo}
开发者ID:pashamray,项目名称:customsw-UNI-T-UT81B,代码行数:33,代码来源:mm.py


示例15: get_g9_device

def get_g9_device():
    for bus in usb.busses():
        for device in bus.devices:
            if device.idVendor == G9_VENDOR_ID \
                    and device.idProduct in G9_PRODUCT_IDS:
                return device.open()
    return None
开发者ID:jeansch,项目名称:g9led,代码行数:7,代码来源:__init__.py


示例16: enumTry

	def enumTry(self):
		busses = usb.busses()
		for bus in busses:
			devices = bus.devices
			for dev in devices:
				print "Devices: ", dev.filename
				print " Device Class: ", dev.deviceClass
				print " Device Subclass: ", dev.deviceSubClass
				print " Device Protocol: ", dev.deviceProtocol
				print " Device max packet size: ", dev.maxPacketSize
				print " ID Vendor: ", dev.idVendor
				print " ID Product: ", dev.idProduct
				print " Device Version: ", dev.deviceVersion
				for config in dev.configurations:
					print "  Configuration: ", config.value
					print "   Total Length: ", config.totalLength
					print "   Self powered: ", config.selfPowered
					print "   Remote Wakeup: ", config.remoteWakeup
					print "   Max Power: ", config.maxPower
					for intf in config.interfaces:
						print "    Interface: ", intf[0].interfaceNumber
						for alt in intf:
							print "    Alternate Setting:",alt.alternateSetting
							print "      Interface class:",alt.interfaceClass
							print "      Interface sub class:",alt.interfaceSubClass
							print "      Interface protocol:",alt.interfaceProtocol
							for ep in alt.endpoints:
								print "      Endpoint:",hex(ep.address)
								print "        Type:",ep.type
								print "        Max packet size:",ep.maxPacketSize
								print "        Interval:",ep.interval
开发者ID:djjazzy,项目名称:PyUSB_Picdem_FS_18F4550,代码行数:31,代码来源:USBHost_PICDEM_FS_USB.py


示例17: find_bricks

def find_bricks(host=None, name=None):
	# FIXME: probably should check host and name
	for bus in usb.busses():
		for device in bus.devices:
			if device.idVendor == ID_VENDOR_LEGO and \
			   device.idProduct == ID_PRODUCT_NXT:
				yield USBSock(device)
开发者ID:aholler,项目名称:nxos,代码行数:7,代码来源:usbsock.py


示例18: _find_device

 def _find_device(idVendor, idProduct):
     for bus in usb.busses():
         for dev in bus.devices:
             if dev.idVendor == idVendor and \
                     dev.idProduct == idProduct:
                 return dev
     return None
开发者ID:Tyres91,项目名称:Logitech-G19-Linux-Daemon,代码行数:7,代码来源:g19.py


示例19: search_usb

def search_usb(device, vendor=None, product=None):
    busses = usb.busses()
    for bus in busses:
        dev = search_usb_bus(bus, device)
        if dev != None:
            return (bus, dev)
    return (None, None)
开发者ID:silicrax,项目名称:killerbee,代码行数:7,代码来源:kbutils.py


示例20: __send_initalization

    def __send_initalization(self):

        usbdev = None
        for bus in usb.busses():
            for dev in bus.devices:
                if dev.idVendor == 0x3333:
                    usbdev = dev
        if usbdev is None:
            raise IOError('Could not find laser device (3333:5555) ...')

        handle = usbdev.open()

        print 'Initializing device ... ',
        initlog = open(os.path.dirname(os.path.abspath(__file__))+'/usbinit.log')

        for line in initlog.readlines():
            setup_packet = line.split('|')[0]
            buf = line.split('|')[-1]
            if len(buf):
                values = setup_packet.strip().split(' ')
                reqType = int(values[0],16)
                req = int(values[1],16)
                value = int(values[2],16)*256+int(values[3],16)
                index = int(values[4],16)*256+int(values[5],16)
                length = int(values[6],16)*256+int(values[7],16)

                binbuf = ''
                for byte in buf.strip().split(' '):
                    binbuf += chr(int(byte,16))

                handle.controlMsg(reqType,req,binbuf,value,index)

        print 'done'
        time.sleep(1)
开发者ID:brmlab,项目名称:laserdisplay,代码行数:34,代码来源:LaserDisplayLocal.py



注:本文中的usb.busses函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _interop.as_array函数代码示例发布时间:2022-05-27
下一篇:
Python usage.constraint函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap