-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathartisanprog.py
executable file
·40 lines (34 loc) · 1.08 KB
/
artisanprog.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
#!/usr/bin/python
import os
import sys
FIFO_WRITE = os.path.dirname(os.path.realpath(__file__)) + '/in.fifo'
FIFO_READ = os.path.dirname(os.path.realpath(__file__)) + '/out.fifo'
def sendCommand(str):
writer = open(FIFO_WRITE, 'w')
writer.write(str)
writer.close()
def sendCommandAndGetResponse(str):
reader = open(FIFO_READ, 'r')
sendCommand(str)
line = reader.readline()
reader.close()
return line
def loadkPaPositions():
f = open(os.path.dirname(os.path.realpath(__file__)) + '/kPaPositions.txt', 'r')
kPaPositions = {}
for line in f:
parts = line.split(':', 2)
kPaPositions[float(parts[0])] = parts[1].strip()
f.close()
print "kPaPositions:"
print kPaPositions
return kPaPositions
if (len(sys.argv) == 1 or sys.argv[1] == 'TMP'):
print sendCommandAndGetResponse("TMP:0").strip()
elif (sys.argv[1] == 'FAN'):
sendCommand("FAN:%s" % sys.argv[2])
elif (sys.argv[1] == 'KPA'):
kPaPositions = loadkPaPositions()
sendCommand("KPA:%s" % kPaPositions[float(sys.argv[2])])
else:
print "Unknown command!"