Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Candidate 20200121 #54

Merged
merged 4 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GroundSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions RoutingService.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 8 additions & 11 deletions Subsystems/cmdGui/CommandSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

#
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -644,6 +641,6 @@ def ProcessQuickButton(self, idx):
#
Command.show()
Command.raise_()
print 'Command System started.'
print ('Command System started.')
sys.exit(app.exec_())

16 changes: 8 additions & 8 deletions Subsystems/cmdGui/HTMLDocsParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import glob
import pickle

from HTMLParser import HTMLParser
from html.parser import HTMLParser
from struct import *

class HTMLDocsParser(HTMLParser):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Subsystems/cmdGui/Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down
8 changes: 4 additions & 4 deletions Subsystems/cmdGui/UdpCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down Expand Up @@ -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
Expand All @@ -183,8 +183,8 @@ def ProcessSendButtonGeneric(self, idx):
# Display usage
#
def usage():
print "Must specify --title=<page name> --file=<cmd_def_file> --pktid=<packet_app_id(hex)> --endian=<LE|BE> --address=<IP address> --port=<UDP 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=<page name> --file=<cmd_def_file> --pktid=<packet_app_id(hex)> --endian=<LE|BE> --address=<IP address> --port=<UDP port>")
print (" example: --title=\"Executive Services\" --file=cfe-es-cmds.txt --pktid=1806 --endian=LE --address=127.0.0.1 --port=1234")

#
# Main
Expand Down
1 change: 1 addition & 0 deletions Subsystems/cmdUtil/cmdUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
19 changes: 10 additions & 9 deletions Subsystems/tlmGUI/EventMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file>"
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=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file>")
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__':
Expand Down Expand Up @@ -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 = '<'
Expand Down
23 changes: 14 additions & 9 deletions Subsystems/tlmGUI/GenericTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ 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':
valueField.setText(hex(TlmField[0]))
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)")
Expand Down Expand Up @@ -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)

Expand All @@ -150,9 +155,9 @@ def run(self):
# Display usage
#
def usage():
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>"
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=<page name> --port=<udp_port> --appid=<packet_app_id(hex)> --endian=<endian(L|B) --file=<tlm_def_file> --sub=<subscriber_string>")
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
Expand Down Expand Up @@ -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 = '<'
Expand All @@ -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] != '#':
Expand Down
21 changes: 10 additions & 11 deletions Subsystems/tlmGUI/TelemetrySystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
#
Expand All @@ -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] != '#':
Expand Down