利用pyusb来查询当前所以usb设备
具体代码如下
#!/usr/bin/python
# -*- coding:utf-8 -*- import sys
import usb.core
# find USB devices
dev = usb.core.find(find_all=True)
# loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct) + '\n')
sys.stdout.write('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct) + '\n\n')
测试结果如下
键盘有插入时usb的情况
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
================== RESTART: C:/Users/libra/Desktop/1111.py ==================
Decimal VendorID=32902 & ProductID=35878
Hexadecimal VendorID=0x8086 & ProductID=0x8c26 Decimal VendorID=32902 & ProductID=35885
Hexadecimal VendorID=0x8086 & ProductID=0x8c2d Decimal VendorID=1133 & ProductID=49948
Hexadecimal VendorID=0x46d & ProductID=0xc31c Decimal VendorID=1266 & ProductID=46001
Hexadecimal VendorID=0x4f2 & ProductID=0xb3b1 Decimal VendorID=7247 & ProductID=81
Hexadecimal VendorID=0x1c4f & ProductID=0x51 Decimal VendorID=32903 & ProductID=32768
Hexadecimal VendorID=0x8087 & ProductID=0x8000 Decimal VendorID=32903 & ProductID=32776
Hexadecimal VendorID=0x8087 & ProductID=0x8008 Decimal VendorID=32902 & ProductID=35889
Hexadecimal VendorID=0x8086 & ProductID=0x8c31
键盘问插入时usb的情况
================== RESTART: C:/Users/libra/Desktop/1111.py ==================
Decimal VendorID=32902 & ProductID=35878
Hexadecimal VendorID=0x8086 & ProductID=0x8c26 Decimal VendorID=32902 & ProductID=35885
Hexadecimal VendorID=0x8086 & ProductID=0x8c2d Decimal VendorID=1266 & ProductID=46001
Hexadecimal VendorID=0x4f2 & ProductID=0xb3b1 Decimal VendorID=7247 & ProductID=81
Hexadecimal VendorID=0x1c4f & ProductID=0x51 Decimal VendorID=32903 & ProductID=32768
Hexadecimal VendorID=0x8087 & ProductID=0x8000 Decimal VendorID=32903 & ProductID=32776
Hexadecimal VendorID=0x8087 & ProductID=0x8008 Decimal VendorID=32902 & ProductID=35889
Hexadecimal VendorID=0x8086 & ProductID=0x8c31
利用pyusb来查询当前所以usb设备的更多相关文章
- 利用mass storage class 做免驱动usb设备.
当需要使用usb bulk传输,想让设备像串口通讯那样和PC主机通信, 通常需要自己做一个PC端的驱动,比较麻烦. 为避免在pc上编写usb设备驱动的麻烦,可以将设备做成mass storage 类的 ...
- C#:基于WMI查询USB设备信息 及 Android设备厂商VID列表
/* ---------------------------------------------------------- 文件名称:WMIUsbQuery.cs 作者:秦建辉 MSN:splashc ...
- C#:基于WMI查询USB设备
来源:http://blog.csdn.net/jhqin/article/details/6734673 /* ------------------------------------------- ...
- windodws pyusb hub端口对应连接的usb设备
源码: 1 #!/usr/bin/python 2 import sys 3 import usb.core 4 # find USB devices 5 dev = usb.core.find(fi ...
- Ubuntu/Windows下利用“HIDAPI”库函数实现与Hid类USB设备通信
一.背景: 最近在做的一个项目需要使用USB传递数据,对USB理解不是很深,USB的系统驱动编写则更是天方 夜谭,因此将设备配置成HID类设备成为了首选.其最大的好处在于,LINUX/Windows系 ...
- Linux下usb设备驱动详解
USB驱动分为两块,一块是USB的bus驱动,这个东西,Linux内核已经做好了,我们可以不管,我们只需要了解它的功能.形象的说,USB的bus驱动相当于铺出一条路来,让所有的信息都可以通过这条USB ...
- 《Linux总线、设备与驱动》USB设备发现机制
说明:本分析基于mstar801平台Linux2.6.35.11内核,其他内核版本仅供参考. 一.程序在内核中的位置 1.usb host做为pci总线下的一个设备存在(嵌入式系统中有可能也会直接挂在 ...
- 嵌入式Linux驱动学习之路(二十)USB设备驱动
USB在接入系统的时候,以0的设备ID和主机通信,然后由主机为其分配新的ID. 在主机端,D+和D-都是下拉接地的.而设备端的D-接上拉时,表明此设备为高速设备:12M/s. D+接上拉时则是全速设备 ...
- C#:USB设备枚举 --转自CSDN作者:Splash
(一)DeviceIoControl的PInvoke /* ---------------------------------------------------------- 文件名称:Device ...
随机推荐
- ALGO-115_蓝桥杯_算法训练_和为T(枚举)
问题描述 从一个大小为n的整数集中选取一些元素,使得它们的和等于给定的值T.每个元素限选一次,不能一个都不选. 输入格式 第一行一个正整数n,表示整数集内元素的个数. 第二行n个整数,用空格隔开. 第 ...
- 【git】之修改git仓库地址
方法1 git remote set-url origin <url> 方法2 git remote rm origin git remote add origin [url] 方法三 直 ...
- 【ApplicationListener】Springboot各类事件监听器
Springboot中SpringApplicationEvent的种类 如下图: 主要包括6种: ApplicationEnvironmentPreparedListener Application ...
- 【Properties】获取Properties文件
获取Properties文件 package com.chinamobile.epic.tako.v2.query.commons; import org.springframework.core.i ...
- MongDB备份error: boost::filesystem::create_directory
用dump 备份一直提示一个error "error: boost::filesystem::create_directory: The filename, directory name, ...
- HEAD插件安装
简介 是一个HTML5编写的集群操作和管理工具,可以对集群进行傻瓜式操作,Head插件中可以显示集群的拓扑结构,执行索引和节点级别等操作,同时也可以输入RESTful命令和Elasticsearch交 ...
- Java学习——读写txt文件
package HHH; import java.io.*; import static java.lang.System.out; public class OpenFile { public st ...
- HDOJ 2005 第几天?
#include<iostream> using namespace std; ] = { ,,,,,,,,,,, }; ] = { ,,,,,,,,,,, }; bool isRYear ...
- [UE4]区分队友
一.就算角色死亡也应该是能区分属于哪个队伍,因此在ShooterPlayerState中添加一个变量Side(并设置为可复制),用来记录所属队伍. 并且在Begin Play事件中随机分配队伍 二.在 ...
- [UE4]自定义函数,快速增加输入参数的一种方法