-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
63 lines (56 loc) · 2.32 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import usb
import pprint
#help(usb.core)
busses = usb.busses()
pp = pprint.PrettyPrinter(indent=4)
for bus in busses:
devices = bus.devices
for dev in devices:
try:
print ("iManufacturer : %s" % usb.util.get_string(dev.dev, 256, 1))
print ("iProduct : %s" % usb.util.get_string(dev.dev, 256, 2))
print ("iSerialNumber : %s" % usb.util.get_string(dev.dev, 256, 3))
print "Device:", dev.filename
print " Device class:",dev.deviceClass
print " Device sub class:",dev.deviceSubClass
print " Device protocol:",dev.deviceProtocol
print " Max packet size:",dev.maxPacketSize
print " idVendor:",hex(dev.idVendor)
print " idProduct:",hex(dev.idProduct)
print " Device Version:",dev.deviceVersion
for config in dev.configurations:
print " Configuration:", config.value
print " Total length:", config.totalLength
print " selfPowered:", config.selfPowered
print " remoteWakeup:", config.remoteWakeup
print " maxPower:", 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
except Exception, msg:
pass
def turn_on_off_mouse():
if dev is None:
print "device not found"
else:
print "device found"
if dev.is_kernel_driver_active(interface) is True:
print "but we need to detach kernel driver"
dev.detach_kernel_driver(interface)
print "claiming device"
usb.util.claim_interface(dev, interface)
print "release claimed interface"
usb.util.release_interface(dev, interface)
print "now attaching the kernel driver again"
dev.attach_kernel_driver(interface)
print "all done"
return 0