diff --git a/GroundSystem.py b/GroundSystem.py index 130757e..5137fe4 100644 --- a/GroundSystem.py +++ b/GroundSystem.py @@ -87,12 +87,12 @@ def startTlmSystem(self): subscription = '--sub=GroundSystem.' + selectedSpacecraft + '.TelemetryPackets' # Open Telemetry System - system_call = '( cd Subsystems/tlmGUI/ && python TelemetrySystem.py ' + subscription + ' ) & ' + system_call = '( cd Subsystems/tlmGUI/ && python3 TelemetrySystem.py ' + subscription + ' ) & ' os.system(system_call) # Start command system def startCmdSystem(self): - os.system('( cd Subsystems/cmdGui/ && python CommandSystem.py ) & ') + os.system('( cd Subsystems/cmdGui/ && python3 CommandSystem.py ) & ') # Start FDL-FUL gui system #def startFDLSystem(self): diff --git a/RoutingService.py b/RoutingService.py index 425dccd..34ddfbb 100644 --- a/RoutingService.py +++ b/RoutingService.py @@ -71,8 +71,6 @@ def run(self): # Receive message datagram, host = self.sock.recvfrom(4096) # buffer size is 1024 bytes - print ('length datagram: %d' % len(datagram)) - # Ignore datagram if it is not long enough (doesnt contain tlm header?) if len(datagram) < 6: continue diff --git a/Subsystems/cmdGui/CommandSystem.py b/Subsystems/cmdGui/CommandSystem.py index ebdd6e4..a656a24 100644 --- a/Subsystems/cmdGui/CommandSystem.py +++ b/Subsystems/cmdGui/CommandSystem.py @@ -144,9 +144,8 @@ def ProcessButtonGeneric(self, idx): lineEditAddress = getattr(Command.ui, 'lineEdit_'+str(idx)) pktId = str(lineEditPktId.text()) address = str(lineEditAddress.text()) - launch_string = 'python ' + cmdClass[0] + ' --title=\"' + cmdPageDesc[idx] + '\" --pktid=' + pktId + ' --file=' + cmdPageDefFile[idx] + ' --address=\"' + address + '\"' + ' --port=' + str(cmdPagePort[idx]) + ' --endian=' + cmdPageEndian[idx] + launch_string = 'python3 ' + cmdClass[0] + ' --title=\"' + cmdPageDesc[idx] + '\" --pktid=' + pktId + ' --file=' + cmdPageDefFile[idx] + ' --address=\"' + address + '\"' + ' --port=' + str(cmdPagePort[idx]) + ' --endian=' + cmdPageEndian[idx] cmd_args = shlex.split(launch_string) - print launch_string subprocess.Popen(cmd_args) # @@ -227,14 +226,12 @@ def ProcessQuickButton(self, idx): # if requires parameters if self.checkParams(quickIdx) == True: - prog = 'python Parameter.py' + prog = 'python3 Parameter.py' 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] # if doesn't require parameters else: launch_string = '../cmdUtil/cmdUtil' + ' --host=\"' + address + '\" --port=' + str(quickPort[quickIdx]) + ' --pktid=' + pktId + ' --endian=' + quickEndian[quickIdx] + ' --cmdcode=' + quickCode[quickIdx] - - # print launch_string cmd_args = shlex.split(launch_string) subprocess.Popen(cmd_args) @@ -269,7 +266,7 @@ def ProcessQuickButton(self, idx): i = 0 - with open(cmdDefFile, 'rb') as cmdfile: + with open(cmdDefFile, 'r') as cmdfile: reader = csv.reader(cmdfile, skipinitialspace = True) for cmdRow in reader: try: @@ -284,9 +281,9 @@ def ProcessQuickButton(self, idx): cmdPagePort.append(int(cmdRow[6])) i += 1 except IndexError: - print "IndexError: list index out of range" - print "This could be due to improper formatting in command-pages.txt." - print "This is a common error caused by blank lines in command-pages.txt" + print ("IndexError: list index out of range") + print ("This could be due to improper formatting in command-pages.txt.") + print ("This is a common error caused by blank lines in command-pages.txt") # # Mark the remaining values as invalid @@ -311,7 +308,7 @@ def ProcessQuickButton(self, idx): quickParam = [] quickIndices = [] - with open(quickDefFile,'rb') as subFile: + with open(quickDefFile,'r') as subFile: reader = csv.reader(subFile) i = 0 for fileRow in reader: @@ -644,6 +641,6 @@ def ProcessQuickButton(self, idx): # Command.show() Command.raise_() - print 'Command System started.' + print ('Command System started.') sys.exit(app.exec_()) diff --git a/Subsystems/cmdGui/HTMLDocsParser.py b/Subsystems/cmdGui/HTMLDocsParser.py index d9992b4..5ae856b 100644 --- a/Subsystems/cmdGui/HTMLDocsParser.py +++ b/Subsystems/cmdGui/HTMLDocsParser.py @@ -26,7 +26,7 @@ import glob import pickle -from HTMLParser import HTMLParser +from html.parser import HTMLParser from struct import * class HTMLDocsParser(HTMLParser): @@ -155,15 +155,15 @@ def findStringLen(self, keyword): stringLen.append(keyword) - print "DATA TYPES:", dataTypesOrig - print "PARAM NAMES: ", paramNames - print "PARAM STRING LEN:", paramLen - print "PARAM DESC: ", paramDesc - print "UNIX DATA TYPES:", dataTypesNew - print "STRING LENGTH:", stringLen, "\n" + print ("DATA TYPES:", dataTypesOrig) + print ("PARAM NAMES: ", paramNames) + print ("PARAM STRING LEN:", paramLen) + print ("PARAM DESC: ", paramDesc) + print ("UNIX DATA TYPES:", dataTypesNew) + print ("STRING LENGTH:", stringLen, "\n") except ValueError: - print "Data Fields not found in HTML file" + print ("Data Fields not found in HTML file") # write data to a file file_split = re.split('/|\.', html_file) diff --git a/Subsystems/cmdGui/Parameter.py b/Subsystems/cmdGui/Parameter.py index 942dae0..7f53f14 100644 --- a/Subsystems/cmdGui/Parameter.py +++ b/Subsystems/cmdGui/Parameter.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui, QtNetwork from ParameterDialog import Ui_Dialog -from HTMLParser import HTMLParser +from html.parser import HTMLParser from HTMLDocsParser import HTMLDocsParser from struct import * diff --git a/Subsystems/cmdGui/UdpCommands.py b/Subsystems/cmdGui/UdpCommands.py index 8a1ea4a..aa389df 100644 --- a/Subsystems/cmdGui/UdpCommands.py +++ b/Subsystems/cmdGui/UdpCommands.py @@ -40,7 +40,7 @@ from PyQt4 import QtGui from GenericCommandDialog import Ui_GenericCommandDialog -from HTMLParser import HTMLParser +from html.parser import HTMLParser from HTMLDocsParser import HTMLDocsParser from struct import * @@ -166,7 +166,7 @@ def ProcessSendButtonGeneric(self, idx): # If parameters are required, launches Parameters page if param_bool == True: - prog = 'python Parameter.py' + prog = 'python3 Parameter.py' 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] # If parameters not required, directly calls cmdUtil to send command @@ -183,8 +183,8 @@ def ProcessSendButtonGeneric(self, idx): # Display usage # def usage(): - print "Must specify --title= --file= --pktid= --endian= --address= --port=" - print " example: --title=\"Executive Services\" --file=cfe-es-cmds.txt --pktid=1806 --endian=LE --address=127.0.0.1 --port=1234" + print ("Must specify --title= --file= --pktid= --endian= --address= --port=") + print (" example: --title=\"Executive Services\" --file=cfe-es-cmds.txt --pktid=1806 --endian=LE --address=127.0.0.1 --port=1234") # # Main diff --git a/Subsystems/cmdUtil/cmdUtil.c b/Subsystems/cmdUtil/cmdUtil.c index 2be768b..7347c98 100644 --- a/Subsystems/cmdUtil/cmdUtil.c +++ b/Subsystems/cmdUtil/cmdUtil.c @@ -109,6 +109,7 @@ static struct option longOpts[] = { { "long", required_argument, NULL, 'l' }, { "double", required_argument, NULL, 'd' }, { "string", required_argument, NULL, 's' }, + { "word", required_argument, NULL, 'l' }, { "help", no_argument, NULL, '?' }, { "verbose", no_argument, NULL, 'v' }, { NULL, no_argument, NULL, 0 } diff --git a/Subsystems/tlmGUI/EventMessage.py b/Subsystems/tlmGUI/EventMessage.py index 6975073..13ed50e 100644 --- a/Subsystems/tlmGUI/EventMessage.py +++ b/Subsystems/tlmGUI/EventMessage.py @@ -99,8 +99,8 @@ def processPendingDatagrams(self, datagram): # # Not accounting for endian right now! # - appName = "".join(unpack("<20s",datagram[12:32])) - eventText = "".join(unpack("<122sxx",datagram[44:])) + appName = datagram[12:32].decode('utf-8','ignore') + eventText = datagram[44:].decode('utf-8','ignore') appName = appName.split("\0")[0] eventText = eventText.split("\0")[0] eventString = "EVENT ---> "+ appName + " : " + eventText @@ -121,24 +121,25 @@ def __init__(self, mainWindow, subscription, appId): self.context = zmq.Context() self.subscriber = self.context.socket(zmq.SUB) self.subscriber.connect("ipc:///tmp/GroundSystem") - self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription) + subscriptionString = str(subscription) + ".Spacecraft1.TelemetryPackets." + str(appId) + self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscriptionString) def run(self): while True: # Read envelope with address [address, datagram] = self.subscriber.recv_multipart() - #print("[%s] %s" % (address, datagram)) + # Ignore if not an event message - if self.appId not in address: continue + if self.appId not in str(address): continue self.emit(self.signalTlmDatagram, datagram) # # Display usage # def usage(): - print "Must specify --title= --port= --appid= --endian=" - print " example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L" - print " (quotes are not on the title string in this example)" + print ("Must specify --title= --port= --appid= --endian=") + print (" example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L") + print (" (quotes are not on the title string in this example)") if __name__ == '__main__': @@ -187,7 +188,7 @@ def usage(): if len(arr) < 3: subscription = 'GroundSystem' - print 'Event Messages Page started. Subscribed to ' + subscription + print ('Event Messages Page started. Subscribed to ' + subscription) if endian == 'L': py_endian = '<' diff --git a/Subsystems/tlmGUI/GenericTelemetry.py b/Subsystems/tlmGUI/GenericTelemetry.py index 6775e31..cb2cf57 100644 --- a/Subsystems/tlmGUI/GenericTelemetry.py +++ b/Subsystems/tlmGUI/GenericTelemetry.py @@ -47,7 +47,11 @@ def __init__(self): # def displayTelemetryItem(self, datagram, tlmIndex, labelField, valueField): if tlmItemIsValid[tlmIndex] == True: - TlmField = unpack(tlmItemFormat[tlmIndex], datagram[int(tlmItemStart[tlmIndex]):(int(tlmItemStart[tlmIndex]) + int(tlmItemSize[tlmIndex]))]) + TlmField1 = tlmItemFormat[tlmIndex] + if TlmField1[:1] == "<": + TlmField1 = TlmField1[1:] + TlmField2 = datagram[int(tlmItemStart[tlmIndex]):(int(tlmItemStart[tlmIndex]) + int(tlmItemSize[tlmIndex]))] + TlmField = unpack( TlmField1, TlmField2) if tlmItemDisplayType[tlmIndex] == 'Dec': valueField.setText(str(TlmField[0])) elif tlmItemDisplayType[tlmIndex] == 'Hex': @@ -55,7 +59,7 @@ def displayTelemetryItem(self, datagram, tlmIndex, labelField, valueField): elif tlmItemDisplayType[tlmIndex] == 'Enm': valueField.setText(tlmItemEnum[tlmIndex][int(TlmField[0])]) elif tlmItemDisplayType[tlmIndex] == 'Str': - valueField.setText(TlmField[0]) + valueField.setText(TlmField[0].decode('utf-8','ignore')) labelField.setText(tlmItemDesc[tlmIndex]) else: labelField.setText("(unused)") @@ -135,13 +139,14 @@ def __init__(self, mainWindow, subscription): self.context = zmq.Context() self.subscriber = self.context.socket(zmq.SUB) self.subscriber.connect("ipc:///tmp/GroundSystem") - self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription) + myTlmPgAPID = subscription.split(".",1) + mySubscription = "GroundSystem.Spacecraft1.TelemetryPackets." + str(myTlmPgAPID[1]) + self.subscriber.setsockopt_string(zmq.SUBSCRIBE, mySubscription) def run(self): while True: # Read envelope with address [address, datagram] = self.subscriber.recv_multipart() - #print("[%s] %s" % (address, datagram)) # Send signal with received packet to front-end/GUI self.emit(self.signalTlmDatagram, datagram) @@ -150,9 +155,9 @@ def run(self): # Display usage # def usage(): - print "Must specify --title= --port= --appid= --endian= --sub=" - print " example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L --sub=GroundSystem.Spacecraft1.0x886" - print " (quotes are not on the title string in this example)" + print ("Must specify --title= --port= --appid= --endian= --sub=") + print (" example: --title=Executive Services --port=10800 --appid=800 --file=cfe-es-hk-table.txt --endian=L --sub=GroundSystem.Spacecraft1.0x886") + print (" (quotes are not on the title string in this example)") # # Main @@ -198,7 +203,7 @@ def usage(): if len(subscription) == 0: subscription = "GroundSystem" - print 'Generic Telemetry Page started. Subscribed to ' + subscription + print ('Generic Telemetry Page started. Subscribed to ' + subscription) if endian == 'L': py_endian = '<' @@ -225,7 +230,7 @@ def usage(): tlmItemEnum = [[] for i in range(40)] i = 0 - with open(tlmDefFile, 'rb') as tlmfile: + with open(tlmDefFile, 'r') as tlmfile: reader = csv.reader(tlmfile, skipinitialspace = True) for row in reader: if row[0][0] != '#': diff --git a/Subsystems/tlmGUI/TelemetrySystem.py b/Subsystems/tlmGUI/TelemetrySystem.py index 825b088..8504acd 100644 --- a/Subsystems/tlmGUI/TelemetrySystem.py +++ b/Subsystems/tlmGUI/TelemetrySystem.py @@ -81,9 +81,9 @@ def dumpPacket(packetData): appIdString = "%02X" % ord(packetData[0]) appIdString = appIdString + "%02X" % ord(packetData[1]) appId = (ord(packetData[0]) << 8) + (ord(packetData[1])) - print "\n-----------------------------------------------" - print "\nPacket: App ID = ", hex(appId) - print "\nPacket Data: ", strToHex(packetData) + print ("\n-----------------------------------------------") + print ("\nPacket: App ID = ", hex(appId)) + print ("\nPacket Data: ", strToHex(packetData)) # # Button press methods @@ -135,7 +135,7 @@ def ProcessButtonGeneric(self, idx): tempSub = self.subscription + '.' + hex(tlmPageAppid[idx]) if tlmPageIsValid[idx] == True: # need to extract data from fields, then start page with right params - launch_string = 'python ' + tlmClass[idx] + ' --title=\"' + tlmPageDesc[idx] + '\" --appid=' + hex(tlmPageAppid[idx]) + ' --port=' + str(tlmPagePort[idx]) + ' --file=' + tlmPageDefFile[idx] + ' --endian=' + endian + ' --sub=' + tempSub + launch_string = 'python3 ' + tlmClass[idx] + ' --title=\"' + tlmPageDesc[idx] + '\" --appid=' + hex(tlmPageAppid[idx]) + ' --port=' + str(tlmPagePort[idx]) + ' --file=' + tlmPageDefFile[idx] + ' --endian=' + endian + ' --sub=' + tempSub cmd_args = shlex.split(launch_string) subprocess.Popen(cmd_args) @@ -168,10 +168,9 @@ def dumpPacket(packetData): appIdString = "%02X" % ord(packetData[0]) appIdString = appIdString + "%02X" % ord(packetData[1]) appId = (ord(packetData[0]) << 8) + (ord(packetData[1])) - print appIdString - print "\nPacket: App ID = ", hex(appId) - print "\nPacket Data: ", strToHex(packetData) - print "\n-----------------------------------------------" + print ("\nPacket: App ID = ", hex(appId)) + print ("\nPacket Data: ", strToHex(packetData)) + print ("\n-----------------------------------------------") # # Show number of packets received @@ -256,7 +255,7 @@ def __init__(self, mainWindow, subscription): self.context = zmq.Context() self.subscriber = self.context.socket(zmq.SUB) self.subscriber.connect("ipc:///tmp/GroundSystem") - self.subscriber.setsockopt(zmq.SUBSCRIBE, subscription) + self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscription) def run(self): while True: @@ -300,7 +299,7 @@ def run(self): if len(subscription) == 0: subscription = "GroundSystem" - print 'Telemetry System started. Subscribed to ' + subscription + print ('Telemetry System started. Subscribed to ' + subscription) # # Read in the contents of the telemetry packet defintion # @@ -313,7 +312,7 @@ def run(self): tlmPageDefFile = [] i = 0 - with open(tlmDefFile, 'rb') as tlmfile: + with open(tlmDefFile, 'r') as tlmfile: reader = csv.reader(tlmfile, skipinitialspace = True) for row in reader: if row[0][0] != '#':