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 |
|
3670 |
kakl |
11 |
if len(sys.argv) < 3 : |
3669 |
kakl |
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: |
3670 |
kakl |
19 |
ser = serial.Serial(sys.argv[1]) |
3669 |
kakl |
20 |
time.sleep(2) |
|
|
21 |
command = sys.argv[2] |
3670 |
kakl |
22 |
for c in command: |
|
|
23 |
ser.write(c) |
|
|
24 |
print("setcol: sending %s" % c) |
|
|
25 |
time.sleep(2) |
3669 |
kakl |
26 |
ser.close() |
|
|
27 |
print("setcol: done") |
|
|
28 |
sys.exit(0) |
|
|
29 |
|
|
|
30 |
except IOError: |
|
|
31 |
print("setcol: can not open device.") |
|
|
32 |
sys.exit(1) |