forked from digistump/DigisparkExamplePrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread.py
More file actions
59 lines (41 loc) · 1.27 KB
/
read.py
File metadata and controls
59 lines (41 loc) · 1.27 KB
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
#/usr/bin/python
#
# Written for PyUSB 1.0 (w/libusb 1.0.3)
#
# Includes functionality to retrieve string descriptors
#
# Author: [email protected]
#
# Version: 20091021
#
#
# Assumes 'UsbStreamDemo1.pde' is loaded on Arduino and
# LEDs are present on pins 11, 12 and 13.
#
import usb # 1.0 not 0.4
import sys
sys.path.append("..")
from arduino.usbdevice import ArduinoUsbDevice
if __name__ == "__main__":
try:
theDevice = ArduinoUsbDevice(idVendor=0x16c0, idProduct=0x05df)
print "Found: 0x%04x 0x%04x %s %s" % (theDevice.idVendor,
theDevice.idProduct,
theDevice.productName,
theDevice.manufacturer)
except:
pass
import sys
import time
while 1 == 1:
try:
theDevice = ArduinoUsbDevice(idVendor=0x16c0, idProduct=0x05df)
try:
sys.stdout.write(chr(theDevice.read()))
sys.stdout.flush()
except:
# TODO: Check for exception properly
time.sleep(0.5)
except:
# TODO: Check for exception properly
time.sleep(1)