Revision 24987,
783 bytes
checked in by jdreed, 14 years ago
(diff) |
Remove DOS linebreaks
|
-
Property svn:executable set to
*
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | # |
---|
3 | # HID interface class = 3 |
---|
4 | # Interface Protocols: |
---|
5 | # 0 - None |
---|
6 | # 1 - KB |
---|
7 | # 2 - Mouse |
---|
8 | # 3-255 Reserved |
---|
9 | |
---|
10 | import usb |
---|
11 | |
---|
12 | protocols = { 1: 'keyboard', |
---|
13 | 2: 'mouse'} |
---|
14 | |
---|
15 | found = { 'keyboard' : 'no', |
---|
16 | 'mouse' : 'no' } |
---|
17 | |
---|
18 | for b in usb.busses(): |
---|
19 | if 'no' not in found.values(): |
---|
20 | break |
---|
21 | for d in b.devices: |
---|
22 | if 'no' not in found.values(): |
---|
23 | break |
---|
24 | i = d.configurations[0].interfaces[0][0] |
---|
25 | if i.interfaceClass == 3 and \ |
---|
26 | i.interfaceProtocol in protocols.keys(): |
---|
27 | found[protocols[i.interfaceProtocol]] = 'yes' |
---|
28 | |
---|
29 | if 'no' not in found.values(): |
---|
30 | print "OK - keyboard and mouse present" |
---|
31 | else: |
---|
32 | errs = [] |
---|
33 | for k,v in found.items(): |
---|
34 | if v == 'no': |
---|
35 | errs.append(k + " missing") |
---|
36 | print "ERROR - " + ', '.join(errs) |
---|
37 | |
---|
Note: See
TracBrowser
for help on using the repository browser.