3669 |
kakl |
1 |
#!/usr/bin/python |
|
|
2 |
# |
|
|
3 |
# Initiating of COLORES |
|
|
4 |
|
|
|
5 |
import sys |
|
|
6 |
import serial |
|
|
7 |
import time |
|
|
8 |
|
|
|
9 |
#### Script Arguments ############################################### |
|
|
10 |
|
|
|
11 |
if len(sys.argv) != 3 : |
|
|
12 |
sys.stderr.write("Invalid number of arguments.\n") |
|
|
13 |
sys.stderr.write("Usage: %s device command\n" % (sys.argv[0], )) |
|
|
14 |
sys.exit(1) |
|
|
15 |
|
|
|
16 |
print("setcol: initiating") |
|
|
17 |
|
|
|
18 |
try: |
|
|
19 |
ser = serial.Serial(sys.argv[1], 9600, timeout=0) |
|
|
20 |
time.sleep(2) |
|
|
21 |
command = sys.argv[2] |
|
|
22 |
ser.write(command) |
|
|
23 |
ser.close() |
|
|
24 |
print("setcol: sending") |
|
|
25 |
time.sleep(len(command)*1.5) |
|
|
26 |
print("setcol: done") |
|
|
27 |
sys.exit(0) |
|
|
28 |
|
|
|
29 |
except IOError: |
|
|
30 |
print("setcol: can not open device.") |
|
|
31 |
sys.exit(1) |