-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnumglobes.py
More file actions
46 lines (34 loc) · 839 Bytes
/
numglobes.py
File metadata and controls
46 lines (34 loc) · 839 Bytes
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
#!/usr/bin/python2
import sys, os, serial, time
hdev = "/dev/ttySP1"
if len(sys.argv) < 1 or len(sys.argv) > 2:
print "Usage: " + sys.argv[0] + " <num_globes>"
sys.exit(1)
if not os.path.exists(hdev):
print "Device " + hdev + " not found"
sys.exit(1)
hd = serial.Serial()
hd.port = hdev
hd.baudrate = 115200
hd.timeout = 1
hd.open()
hd.flushInput()
hd.write("?")
resp = hd.readline()
resp = resp.strip()
if not resp.startswith("HolidayDuino"):
print "Unexpected response: " + resp
hd.close()
sys.exit(2)
print "Response: " + resp
if len(sys.argv) == 2:
hd.write(sys.argv[1])
hd.write("L")
resp = hd.readline()
resp = resp.strip()
print "Response: " + resp
hd.close()
if len(sys.argv) == 2 and resp == sys.argv[1]:
print "Rebooting HolidayDuino"
time.sleep(1)
os.system("/home/holiday/scripts/reduino.sh")