-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPQ9BusFromFile.py
More file actions
44 lines (39 loc) · 1.38 KB
/
PQ9BusFromFile.py
File metadata and controls
44 lines (39 loc) · 1.38 KB
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
import PQ9Client
import sys
import time
if __name__ == "__main__":
pq9client = PQ9Client.PQ9Client("localhost","10000")
pq9client.connect()
# comPortName = sys.argv[1]
# dest = sys.argv[2]
# inputFileName = sys.argv[3]
# print("Connecting PC_EGSE to COMPORT: "+comPortName)
# command = {}
# command["command"] = "reloadSerialPorts"
# pq9client.sendFrame(command)
# command["command"] = "setSerialPort"
# command["data"] = comPortName
# pq9client.sendFrame(command)
# time.sleep(3)
inputFileName = sys.argv[2]
dest = sys.argv[1]
print("Opening file: "+inputFileName)
fi = open(inputFileName, "r")
fo = open(inputFileName+"_response", 'w')
commandlines = fi.readlines()
startTime= time.time()
for i,commandline in enumerate(commandlines):
command = {}
command["_send_"] = "SendRaw"
command["dest"] = dest
command["src"] = "8"
command["data"] = commandline.rstrip("\n")
pq9client.sendFrame(command)
succes, msg = pq9client.getFrame()
if(succes):
msg = msg['_raw_']
print("%.2f" % (100 * i/(len(commandlines)-1)) + "%" )
fo.write(msg.replace('[','').replace(']','').replace(',','') + '\n' )
else:
break
print("Elapsed Time: %.2f" % (time.time()-startTime))