-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdalitest.py
executable file
·48 lines (37 loc) · 966 Bytes
/
dalitest.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
#!/usr/bin/env python
import serial
import sys
import time
device = sys.argv[1]
ser = serial.Serial(device, baudrate=115200, timeout=1)
units = [0, 1, 2, 5, 8, 7, 4]
def msg(data):
# packet starts with the number of message bytes
buf = [len(data)]
# then the message
buf.extend(data)
# add a null in case we get out of sync
# (a null on its own will be interpreted as a zero-length message)
buf.append(0)
# send the data over serial
ser.write(buf)
ser.flush()
def chase(t=0.25):
while True:
for i in range(0, len(units)):
a = units[i]
b = units[i % len(units)-1]
msg([a << 1, 254, b << 1, 1])
time.sleep(t)
def flash(t=0.5):
while True:
msg([254, 254])
time.sleep(t)
msg([254, 1])
time.sleep(t)
try:
chase(0.6)
#flash()
except KeyboardInterrupt:
for unit in units:
msg([unit << 1, 254])