diff --git a/OBSW_TmTcClient.py b/OBSW_TmTcClient.py index 73c2944c7c2229994b69eb97bafa0a35c2eecec2..04f312459cd713cafe67523a5e35452f95894a03 100644 --- a/OBSW_TmTcClient.py +++ b/OBSW_TmTcClient.py @@ -124,7 +124,7 @@ def commandPreparation(): # file = bytearray([1, 2, 3, 4, 5]) # command = PUSTelecommand(service=23, subservice=1, SSC=21, data=file) # command.packCommandTuple() - # return command.packCommandTuple() + return command.packCommandTuple() def setUpSocket(): @@ -141,17 +141,21 @@ def setUpSocket(): def setCommunicationInterface(tmtcPrinter): - if g.comIF == 0: - setUpSocket() - connectToBoard() - communicationInterface = EthernetComIF(tmtcPrinter, g.tmTimeout, g.tcSendTimeoutFactor, - g.sockSend, g.sockReceive, g.sendAddress) - else: - comPort = g.comPort - baudRate = 115200 - g.serialTimeout = 0.05 - communicationInterface = SerialComIF(tmtcPrinter, comPort, baudRate, g.serialTimeout) - return communicationInterface + try: + if g.comIF == 0: + setUpSocket() + connectToBoard() + communicationInterface = EthernetComIF(tmtcPrinter, g.tmTimeout, g.tcSendTimeoutFactor, + g.sockSend, g.sockReceive, g.sendAddress) + else: + comPort = g.comPort + baudRate = 115200 + g.serialTimeout = 0.05 + communicationInterface = SerialComIF(tmtcPrinter, comPort, baudRate, g.serialTimeout) + return communicationInterface + except (IOError, OSError) as e: + print("Error setting up communication interface, Error: " + str(e)) + return exit() class GracefulKiller: diff --git a/tm/OBSW_TmService3.py b/tm/OBSW_TmService3.py index fbc1b1225ecee6731a522c203f30da5d30b02ee2..87440a9f49d1a7a913e665447ad18c1fa8b466ee 100644 --- a/tm/OBSW_TmService3.py +++ b/tm/OBSW_TmService3.py @@ -13,11 +13,14 @@ import struct class Service3TM(PUSTelemetry): def __init__(self, byteArray): super().__init__(byteArray) + print("Length of data: " + str(len(self.byteArrayData))) self.sid = struct.unpack('>I', self.byteArrayData[0:4])[0] self.hkHeader = [] self.hkContent = [] self.hkDefinitionHeader = [] self.hkDefinition = [] + self.numberOfParameters = 0 + self.validityBuffer = [] self.printPacketInfo("Housekeeping Packet") self.paramLength = 0 if self.getSubservice() == 10 or self.getSubservice() == 12: @@ -60,30 +63,42 @@ class Service3TM(PUSTelemetry): self.paramLength = len(self.byteArrayData) - 4 # TODO: This can be automated by using the MIB parser pool names and pool datatypes if self.sid == 0x1f00 or self.sid == 0x2f00: - self.hkHeader = ["Fix Mode", "SV in Fix", "GNSS Week", "Time of Week", "Latitude", "Longitude", - "Mean Sea Altitude", "Position X", "Position Y", "Position Z", - "Velocity X", "Velocity Y", "Velocity Z"] - fixMode = self.byteArrayData[4] - svInFix = self.byteArrayData[5] - gnssWeek = struct.unpack('>H', self.byteArrayData[6:8])[0] - timeOfWeek = struct.unpack('>I', self.byteArrayData[8:12])[0] - latitude = struct.unpack('>I', self.byteArrayData[12:16])[0] - longitude = struct.unpack('>I', self.byteArrayData[16:20])[0] - msa = struct.unpack('>I', self.byteArrayData[20:24])[0] - positionX = struct.unpack('>d', self.byteArrayData[24:32])[0] - positionY = struct.unpack('>d', self.byteArrayData[32:40])[0] - positionZ = struct.unpack('>d', self.byteArrayData[40:48])[0] - vx = struct.unpack('>d', self.byteArrayData[48:56])[0] - vy = struct.unpack('>d', self.byteArrayData[56:64])[0] - vz = struct.unpack('>d', self.byteArrayData[64:72])[0] - self.hkContent = [fixMode, svInFix, gnssWeek, timeOfWeek, latitude, longitude, msa, positionX, positionY, - positionZ, vx, vy, vz] + self.handleGpsHkData() elif self.sid == 0x4300 or self.sid == 0x4400: - self.hkHeader = ["Bool", "UINT8", "UINT16", "UINT32", "FLOAT1", "FLOAT2"] - testBool = self.byteArrayData[4] - testUint8 = self.byteArrayData[5] - testUint16 = (self.byteArrayData[6] << 8) | self.byteArrayData[7] - testUint32 = struct.unpack('>I', self.byteArrayData[8:12])[0] - floatVector1 = struct.unpack('>f', self.byteArrayData[12:16])[0] - floatVector2 = struct.unpack('>f', self.byteArrayData[16:20])[0] - self.hkContent = [testBool, testUint8, testUint16, testUint32, floatVector1, floatVector2] + self.handleTestHkData() + + def handleGpsHkData(self): + self.numberOfParameters = 9 + self.hkHeader = ["Fix Mode", "SV in Fix", "GNSS Week", "Time of Week", "Latitude", "Longitude", + "Mean Sea Altitude", "Position X", "Position Y", "Position Z", + "Velocity X", "Velocity Y", "Velocity Z"] + fixMode = self.byteArrayData[4] + svInFix = self.byteArrayData[5] + gnssWeek = struct.unpack('>H', self.byteArrayData[6:8])[0] + timeOfWeek = struct.unpack('>I', self.byteArrayData[8:12])[0] + latitude = struct.unpack('>I', self.byteArrayData[12:16])[0] + longitude = struct.unpack('>I', self.byteArrayData[16:20])[0] + msa = struct.unpack('>I', self.byteArrayData[20:24])[0] + positionX = struct.unpack('>d', self.byteArrayData[24:32])[0] + positionY = struct.unpack('>d', self.byteArrayData[32:40])[0] + positionZ = struct.unpack('>d', self.byteArrayData[40:48])[0] + vx = struct.unpack('>d', self.byteArrayData[48:56])[0] + vy = struct.unpack('>d', self.byteArrayData[56:64])[0] + vz = struct.unpack('>d', self.byteArrayData[64:72])[0] + self.hkContent = [fixMode, svInFix, gnssWeek, timeOfWeek, latitude, longitude, msa, positionX, positionY, + positionZ, vx, vy, vz] + self.validityBuffer = self.byteArrayData[72:] + print("Validity Buffer Length: " + str(self.validityBuffer)) + + def handleTestHkData(self): + self.numberOfParameters = 6 + self.hkHeader = ["Bool", "UINT8", "UINT16", "UINT32", "FLOAT1", "FLOAT2"] + testBool = self.byteArrayData[4] + testUint8 = self.byteArrayData[5] + testUint16 = (self.byteArrayData[6] << 8) | self.byteArrayData[7] + testUint32 = struct.unpack('>I', self.byteArrayData[8:12])[0] + floatVector1 = struct.unpack('>f', self.byteArrayData[12:16])[0] + floatVector2 = struct.unpack('>f', self.byteArrayData[16:20])[0] + self.hkContent = [testBool, testUint8, testUint16, testUint32, floatVector1, floatVector2] + self.validityBuffer = self.byteArrayData[20:] + print("Validity Buffer Length: " + str(self.validityBuffer))