Skip to content

Commit 343d8b3

Browse files
authored
Merge pull request #54 from nasa/ic-20200121
Integration Candidate 20200121
2 parents 4d7f8b5 + 0e26033 commit 343d8b3

File tree

10 files changed

+58
-57
lines changed

10 files changed

+58
-57
lines changed

GroundSystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ def startTlmSystem(self):
8787
subscription = '--sub=GroundSystem.' + selectedSpacecraft + '.TelemetryPackets'
8888

8989
# Open Telemetry System
90-
system_call = '( cd Subsystems/tlmGUI/ && python TelemetrySystem.py ' + subscription + ' ) & '
90+
system_call = '( cd Subsystems/tlmGUI/ && python3 TelemetrySystem.py ' + subscription + ' ) & '
9191
os.system(system_call)
9292

9393
# Start command system
9494
def startCmdSystem(self):
95-
os.system('( cd Subsystems/cmdGui/ && python CommandSystem.py ) & ')
95+
os.system('( cd Subsystems/cmdGui/ && python3 CommandSystem.py ) & ')
9696

9797
# Start FDL-FUL gui system
9898
#def startFDLSystem(self):

RoutingService.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ def run(self):
7171
# Receive message
7272
datagram, host = self.sock.recvfrom(4096) # buffer size is 1024 bytes
7373

74-
print ('length datagram: %d' % len(datagram))
75-
7674
# Ignore datagram if it is not long enough (doesnt contain tlm header?)
7775
if len(datagram) < 6:
7876
continue

Subsystems/cmdGui/CommandSystem.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ def ProcessButtonGeneric(self, idx):
144144
lineEditAddress = getattr(Command.ui, 'lineEdit_'+str(idx))
145145
pktId = str(lineEditPktId.text())
146146
address = str(lineEditAddress.text())
147-
launch_string = 'python ' + cmdClass[0] + ' --title=\"' + cmdPageDesc[idx] + '\" --pktid=' + pktId + ' --file=' + cmdPageDefFile[idx] + ' --address=\"' + address + '\"' + ' --port=' + str(cmdPagePort[idx]) + ' --endian=' + cmdPageEndian[idx]
147+
launch_string = 'python3 ' + cmdClass[0] + ' --title=\"' + cmdPageDesc[idx] + '\" --pktid=' + pktId + ' --file=' + cmdPageDefFile[idx] + ' --address=\"' + address + '\"' + ' --port=' + str(cmdPagePort[idx]) + ' --endian=' + cmdPageEndian[idx]
148148
cmd_args = shlex.split(launch_string)
149-
print launch_string
150149
subprocess.Popen(cmd_args)
151150

152151
#
@@ -227,14 +226,12 @@ def ProcessQuickButton(self, idx):
227226

228227
# if requires parameters
229228
if self.checkParams(quickIdx) == True:
230-
prog = 'python Parameter.py'
229+
prog = 'python3 Parameter.py'
231230
launch_string = prog+' --title=\"'+subsys[quickIdx]+'\" --descrip=\"'+quickCmd[quickIdx]+'\" --idx='+str(idx)+' --host=\"'+address+'\" --port='+str(quickPort[quickIdx])+' --pktid='+pktId+' --endian='+quickEndian[quickIdx]+' --cmdcode='+quickCode[quickIdx]+' --file='+quickParam[quickIdx]
232231

233232
# if doesn't require parameters
234233
else:
235234
launch_string = '../cmdUtil/cmdUtil' + ' --host=\"' + address + '\" --port=' + str(quickPort[quickIdx]) + ' --pktid=' + pktId + ' --endian=' + quickEndian[quickIdx] + ' --cmdcode=' + quickCode[quickIdx]
236-
237-
# print launch_string
238235
cmd_args = shlex.split(launch_string)
239236
subprocess.Popen(cmd_args)
240237

@@ -269,7 +266,7 @@ def ProcessQuickButton(self, idx):
269266

270267
i = 0
271268

272-
with open(cmdDefFile, 'rb') as cmdfile:
269+
with open(cmdDefFile, 'r') as cmdfile:
273270
reader = csv.reader(cmdfile, skipinitialspace = True)
274271
for cmdRow in reader:
275272
try:
@@ -284,9 +281,9 @@ def ProcessQuickButton(self, idx):
284281
cmdPagePort.append(int(cmdRow[6]))
285282
i += 1
286283
except IndexError:
287-
print "IndexError: list index out of range"
288-
print "This could be due to improper formatting in command-pages.txt."
289-
print "This is a common error caused by blank lines in command-pages.txt"
284+
print ("IndexError: list index out of range")
285+
print ("This could be due to improper formatting in command-pages.txt.")
286+
print ("This is a common error caused by blank lines in command-pages.txt")
290287

291288
#
292289
# Mark the remaining values as invalid
@@ -311,7 +308,7 @@ def ProcessQuickButton(self, idx):
311308
quickParam = []
312309
quickIndices = []
313310

314-
with open(quickDefFile,'rb') as subFile:
311+
with open(quickDefFile,'r') as subFile:
315312
reader = csv.reader(subFile)
316313
i = 0
317314
for fileRow in reader:
@@ -644,6 +641,6 @@ def ProcessQuickButton(self, idx):
644641
#
645642
Command.show()
646643
Command.raise_()
647-
print 'Command System started.'
644+
print ('Command System started.')
648645
sys.exit(app.exec_())
649646

Subsystems/cmdGui/HTMLDocsParser.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import glob
2727
import pickle
2828

29-
from HTMLParser import HTMLParser
29+
from html.parser import HTMLParser
3030
from struct import *
3131

3232
class HTMLDocsParser(HTMLParser):
@@ -155,15 +155,15 @@ def findStringLen(self, keyword):
155155
stringLen.append(keyword)
156156

157157

158-
print "DATA TYPES:", dataTypesOrig
159-
print "PARAM NAMES: ", paramNames
160-
print "PARAM STRING LEN:", paramLen
161-
print "PARAM DESC: ", paramDesc
162-
print "UNIX DATA TYPES:", dataTypesNew
163-
print "STRING LENGTH:", stringLen, "\n"
158+
print ("DATA TYPES:", dataTypesOrig)
159+
print ("PARAM NAMES: ", paramNames)
160+
print ("PARAM STRING LEN:", paramLen)
161+
print ("PARAM DESC: ", paramDesc)
162+
print ("UNIX DATA TYPES:", dataTypesNew)
163+
print ("STRING LENGTH:", stringLen, "\n")
164164

165165
except ValueError:
166-
print "Data Fields not found in HTML file"
166+
print ("Data Fields not found in HTML file")
167167

168168
# write data to a file
169169
file_split = re.split('/|\.', html_file)

Subsystems/cmdGui/Parameter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from PyQt4 import QtGui, QtNetwork
2929
from ParameterDialog import Ui_Dialog
30-
from HTMLParser import HTMLParser
30+
from html.parser import HTMLParser
3131
from HTMLDocsParser import HTMLDocsParser
3232
from struct import *
3333

Subsystems/cmdGui/UdpCommands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
from PyQt4 import QtGui
4242
from GenericCommandDialog import Ui_GenericCommandDialog
43-
from HTMLParser import HTMLParser
43+
from html.parser import HTMLParser
4444
from HTMLDocsParser import HTMLDocsParser
4545
from struct import *
4646

@@ -166,7 +166,7 @@ def ProcessSendButtonGeneric(self, idx):
166166

167167
# If parameters are required, launches Parameters page
168168
if param_bool == True:
169-
prog = 'python Parameter.py'
169+
prog = 'python3 Parameter.py'
170170
launch_string = prog+' --title=\"'+pageTitle+'\" --descrip=\"'+cmdDesc[idx]+'\" --idx='+str(idx)+' --host=\"'+address+'\" --port='+str(pagePort)+' --pktid='+str(pagePktId)+' --endian='+pageEndian+' --cmdcode='+cmdCodes[idx]+' --file='+param_files[idx]
171171

172172
# If parameters not required, directly calls cmdUtil to send command
@@ -183,8 +183,8 @@ def ProcessSendButtonGeneric(self, idx):
183183
# Display usage
184184
#
185185
def usage():
186-
print "Must specify --title=<page name> --file=<cmd_def_file> --pktid=<packet_app_id(hex)> --endian=<LE|BE> --address=<IP address> --port=<UDP port>"
187-
print " example: --title=\"Executive Services\" --file=cfe-es-cmds.txt --pktid=1806 --endian=LE --address=127.0.0.1 --port=1234"
186+
print ("Must specify --title=<page name> --file=<cmd_def_file> --pktid=<packet_app_id(hex)> --endian=<LE|BE> --address=<IP address> --port=<UDP port>")
187+
print (" example: --title=\"Executive Services\" --file=cfe-es-cmds.txt --pktid=1806 --endian=LE --address=127.0.0.1 --port=1234")
188188

189189
#
190190
# Main

Subsystems/cmdUtil/cmdUtil.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static struct option longOpts[] = {
109109
{ "long", required_argument, NULL, 'l' },
110110
{ "double", required_argument, NULL, 'd' },
111111
{ "string", required_argument, NULL, 's' },
112+
{ "word", required_argument, NULL, 'l' },
112113
{ "help", no_argument, NULL, '?' },
113114
{ "verbose", no_argument, NULL, 'v' },
114115
{ NULL, no_argument, NULL, 0 }

Subsystems/tlmGUI/EventMessage.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def processPendingDatagrams(self, datagram):
9999
#
100100
# Not accounting for endian right now!
101101
#
102-
appName = "".join(unpack("<20s",datagram[12:32]))
103-
eventText = "".join(unpack("<122sxx",datagram[44:]))
102+
appName = datagram[12:32].decode('utf-8','ignore')
103+
eventText = datagram[44:].decode('utf-8','ignore')
104104
appName = appName.split("\0")[0]
105105
eventText = eventText.split("\0")[0]
106106
eventString = "EVENT ---> "+ appName + " : " + eventText
@@ -121,24 +121,25 @@ def __init__(self, mainWindow, subscription, appId):
121121
self.context = zmq.Context()
122122
self.subscriber = self.context.socket(zmq.SUB)
123123
self.subscriber.connect("ipc:///tmp/GroundSystem")
124-
self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription)
124+
subscriptionString = str(subscription) + ".Spacecraft1.TelemetryPackets." + str(appId)
125+
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscriptionString)
125126

126127
def run(self):
127128
while True:
128129
# Read envelope with address
129130
[address, datagram] = self.subscriber.recv_multipart()
130-
#print("[%s] %s" % (address, datagram))
131+
131132
# Ignore if not an event message
132-
if self.appId not in address: continue
133+
if self.appId not in str(address): continue
133134
self.emit(self.signalTlmDatagram, datagram)
134135

135136
#
136137
# Display usage
137138
#
138139
def usage():
139-
print "Must specify --title=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file>"
140-
print " example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L"
141-
print " (quotes are not on the title string in this example)"
140+
print ("Must specify --title=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file>")
141+
print (" example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L")
142+
print (" (quotes are not on the title string in this example)")
142143

143144

144145
if __name__ == '__main__':
@@ -187,7 +188,7 @@ def usage():
187188
if len(arr) < 3:
188189
subscription = 'GroundSystem'
189190

190-
print 'Event Messages Page started. Subscribed to ' + subscription
191+
print ('Event Messages Page started. Subscribed to ' + subscription)
191192

192193
if endian == 'L':
193194
py_endian = '<'

Subsystems/tlmGUI/GenericTelemetry.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,19 @@ def __init__(self):
4747
#
4848
def displayTelemetryItem(self, datagram, tlmIndex, labelField, valueField):
4949
if tlmItemIsValid[tlmIndex] == True:
50-
TlmField = unpack(tlmItemFormat[tlmIndex], datagram[int(tlmItemStart[tlmIndex]):(int(tlmItemStart[tlmIndex]) + int(tlmItemSize[tlmIndex]))])
50+
TlmField1 = tlmItemFormat[tlmIndex]
51+
if TlmField1[:1] == "<":
52+
TlmField1 = TlmField1[1:]
53+
TlmField2 = datagram[int(tlmItemStart[tlmIndex]):(int(tlmItemStart[tlmIndex]) + int(tlmItemSize[tlmIndex]))]
54+
TlmField = unpack( TlmField1, TlmField2)
5155
if tlmItemDisplayType[tlmIndex] == 'Dec':
5256
valueField.setText(str(TlmField[0]))
5357
elif tlmItemDisplayType[tlmIndex] == 'Hex':
5458
valueField.setText(hex(TlmField[0]))
5559
elif tlmItemDisplayType[tlmIndex] == 'Enm':
5660
valueField.setText(tlmItemEnum[tlmIndex][int(TlmField[0])])
5761
elif tlmItemDisplayType[tlmIndex] == 'Str':
58-
valueField.setText(TlmField[0])
62+
valueField.setText(TlmField[0].decode('utf-8','ignore'))
5963
labelField.setText(tlmItemDesc[tlmIndex])
6064
else:
6165
labelField.setText("(unused)")
@@ -135,13 +139,14 @@ def __init__(self, mainWindow, subscription):
135139
self.context = zmq.Context()
136140
self.subscriber = self.context.socket(zmq.SUB)
137141
self.subscriber.connect("ipc:///tmp/GroundSystem")
138-
self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription)
142+
myTlmPgAPID = subscription.split(".",1)
143+
mySubscription = "GroundSystem.Spacecraft1.TelemetryPackets." + str(myTlmPgAPID[1])
144+
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, mySubscription)
139145

140146
def run(self):
141147
while True:
142148
# Read envelope with address
143149
[address, datagram] = self.subscriber.recv_multipart()
144-
#print("[%s] %s" % (address, datagram))
145150
# Send signal with received packet to front-end/GUI
146151
self.emit(self.signalTlmDatagram, datagram)
147152

@@ -150,9 +155,9 @@ def run(self):
150155
# Display usage
151156
#
152157
def usage():
153-
print "Must specify --title=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file> --sub=<subscriber_string>"
154-
print " example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L --sub=GroundSystem.Spacecraft1.0x886"
155-
print " (quotes are not on the title string in this example)"
158+
print ("Must specify --title=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file> --sub=<subscriber_string>")
159+
print (" example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L --sub=GroundSystem.Spacecraft1.0x886")
160+
print (" (quotes are not on the title string in this example)")
156161

157162
#
158163
# Main
@@ -198,7 +203,7 @@ def usage():
198203
if len(subscription) == 0:
199204
subscription = "GroundSystem"
200205

201-
print 'Generic Telemetry Page started. Subscribed to ' + subscription
206+
print ('Generic Telemetry Page started. Subscribed to ' + subscription)
202207

203208
if endian == 'L':
204209
py_endian = '<'
@@ -225,7 +230,7 @@ def usage():
225230
tlmItemEnum = [[] for i in range(40)]
226231
i = 0
227232

228-
with open(tlmDefFile, 'rb') as tlmfile:
233+
with open(tlmDefFile, 'r') as tlmfile:
229234
reader = csv.reader(tlmfile, skipinitialspace = True)
230235
for row in reader:
231236
if row[0][0] != '#':

Subsystems/tlmGUI/TelemetrySystem.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def dumpPacket(packetData):
8181
appIdString = "%02X" % ord(packetData[0])
8282
appIdString = appIdString + "%02X" % ord(packetData[1])
8383
appId = (ord(packetData[0]) << 8) + (ord(packetData[1]))
84-
print "\n-----------------------------------------------"
85-
print "\nPacket: App ID = ", hex(appId)
86-
print "\nPacket Data: ", strToHex(packetData)
84+
print ("\n-----------------------------------------------")
85+
print ("\nPacket: App ID = ", hex(appId))
86+
print ("\nPacket Data: ", strToHex(packetData))
8787

8888
#
8989
# Button press methods
@@ -135,7 +135,7 @@ def ProcessButtonGeneric(self, idx):
135135
tempSub = self.subscription + '.' + hex(tlmPageAppid[idx])
136136
if tlmPageIsValid[idx] == True:
137137
# need to extract data from fields, then start page with right params
138-
launch_string = 'python ' + tlmClass[idx] + ' --title=\"' + tlmPageDesc[idx] + '\" --appid=' + hex(tlmPageAppid[idx]) + ' --port=' + str(tlmPagePort[idx]) + ' --file=' + tlmPageDefFile[idx] + ' --endian=' + endian + ' --sub=' + tempSub
138+
launch_string = 'python3 ' + tlmClass[idx] + ' --title=\"' + tlmPageDesc[idx] + '\" --appid=' + hex(tlmPageAppid[idx]) + ' --port=' + str(tlmPagePort[idx]) + ' --file=' + tlmPageDefFile[idx] + ' --endian=' + endian + ' --sub=' + tempSub
139139
cmd_args = shlex.split(launch_string)
140140
subprocess.Popen(cmd_args)
141141

@@ -168,10 +168,9 @@ def dumpPacket(packetData):
168168
appIdString = "%02X" % ord(packetData[0])
169169
appIdString = appIdString + "%02X" % ord(packetData[1])
170170
appId = (ord(packetData[0]) << 8) + (ord(packetData[1]))
171-
print appIdString
172-
print "\nPacket: App ID = ", hex(appId)
173-
print "\nPacket Data: ", strToHex(packetData)
174-
print "\n-----------------------------------------------"
171+
print ("\nPacket: App ID = ", hex(appId))
172+
print ("\nPacket Data: ", strToHex(packetData))
173+
print ("\n-----------------------------------------------")
175174

176175
#
177176
# Show number of packets received
@@ -256,7 +255,7 @@ def __init__(self, mainWindow, subscription):
256255
self.context = zmq.Context()
257256
self.subscriber = self.context.socket(zmq.SUB)
258257
self.subscriber.connect("ipc:///tmp/GroundSystem")
259-
self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription)
258+
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscription)
260259

261260
def run(self):
262261
while True:
@@ -300,7 +299,7 @@ def run(self):
300299
if len(subscription) == 0:
301300
subscription = "GroundSystem"
302301

303-
print 'Telemetry System started. Subscribed to ' + subscription
302+
print ('Telemetry System started. Subscribed to ' + subscription)
304303
#
305304
# Read in the contents of the telemetry packet defintion
306305
#
@@ -313,7 +312,7 @@ def run(self):
313312
tlmPageDefFile = []
314313
i = 0
315314

316-
with open(tlmDefFile, 'rb') as tlmfile:
315+
with open(tlmDefFile, 'r') as tlmfile:
317316
reader = csv.reader(tlmfile, skipinitialspace = True)
318317
for row in reader:
319318
if row[0][0] != '#':

0 commit comments

Comments
 (0)