使用pyusb读取USB设备的输入

 1 import usb.core
 2
 3 dev = usb.core.find(idVendor=0x17ef,idProduct = 0x600e)
 4 ep = dev[0].interfaces()[0].endpoints()[0]
 5 
 6
 7 i = dev[0].interfaces()[0].bInterfaceNumber
 8  
 9
10 dev.reset()
11
12 if dev.is_kernel_driver_active(i):
13     dev.detach_kernel_driver(i)
14
15 dev.set_configuration()
16
17 eaddr = ep.bEndpointAddress
18
19
20 r = dev.read(eaddr,500)
21 print(r)

 

posted @ 2022-12-05 22:39  华小电  阅读(511)  评论(0编辑  收藏  举报