-
Notifications
You must be signed in to change notification settings - Fork 56
/
try.py
45 lines (33 loc) · 1.07 KB
/
try.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
import hid
import time
for d in hid.enumerate(0, 0):
keys = d.keys()
keys.sort()
for key in keys:
print "%s : %s" % (key, d[key])
print ""
try:
print "Opening device"
h = hid.device(0x461, 0x20)
#h = hid.device(0x1941, 0x8021) # Fine Offset USB Weather Station
print "Manufacturer: %s" % h.get_manufacturer_string()
print "Product: %s" % h.get_product_string()
print "Serial No: %s" % h.get_serial_number_string()
# try non-blocking mode by uncommenting the next line
#h.set_nonblocking(1)
# try writing some data to the device
for k in range(10):
for i in [0, 1]:
for j in [0, 1]:
h.write([0x80, i, j])
d = h.read(5)
if d:
print d
time.sleep(0.05)
print "Closing device"
h.close()
except IOError, ex:
print ex
print "You probably don't have the hard coded test hid. Update the hid.device line"
print "in this script with one from the enumeration list output above and try again."
print "Done"