diff --git a/.idea/runConfigurations/OBSW_UdpClient_Service_3_Serial_.xml b/.idea/runConfigurations/OBSW_UdpClient_Service_3_Serial_.xml index 7a1d8a78ab126f01d06c6bbd87d0e56f42fe2807..ded0da255f7f8546938e02734ce809f2e4303e61 100644 --- a/.idea/runConfigurations/OBSW_UdpClient_Service_3_Serial_.xml +++ b/.idea/runConfigurations/OBSW_UdpClient_Service_3_Serial_.xml @@ -12,8 +12,8 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="C:\Users\Robin\NoSyncDokumente\sourceobsw\tmtc\OBSW_TmTcClient.py" /> - <option name="PARAMETERS" value="-m 3 -s 3 -p -c 1 -t 4" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" /> + <option name="PARAMETERS" value="-m 3 -s 3 -p -c 1 -t 4 --hk" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> <option name="MODULE_MODE" value="false" /> diff --git a/.idea/runConfigurations/OBSW_UdpClient_Single_Command_Serial.xml b/.idea/runConfigurations/OBSW_UdpClient_Single_Command_Serial.xml index b2b8e994df14202fe7e47a25953dc61f8bab3984..8b5bad493068e0c8d4993247fdaa84ec02d9d58d 100644 --- a/.idea/runConfigurations/OBSW_UdpClient_Single_Command_Serial.xml +++ b/.idea/runConfigurations/OBSW_UdpClient_Single_Command_Serial.xml @@ -12,8 +12,8 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="C:\Users\Robin\NoSyncDokumente\sourceobsw\tmtc\OBSW_TmTcClient.py" /> - <option name="PARAMETERS" value="-m 2 -c 1" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" /> + <option name="PARAMETERS" value="-m 2 -c 1 --COM COM9" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> <option name="MODULE_MODE" value="false" /> diff --git a/OBSW_TmTcClient.py b/OBSW_TmTcClient.py index 8994970e96aaf28449d8f1f9d037a4d3e0c2f5e4..0cbaa95e51976d5bfb748edb7257610655610789 100644 --- a/OBSW_TmTcClient.py +++ b/OBSW_TmTcClient.py @@ -74,7 +74,6 @@ from comIF.OBSW_Serial_ComIF import SerialComIF def main(): args = parseInputArguments() setGlobals(args) - setUpSocket() atexit.register(g.keyboardInterruptHandler) tmtcPrinter = TmtcPrinter(g.displayMode, g.printToFile, True) communicationInterface = setCommunicationInterface(tmtcPrinter) @@ -121,7 +120,7 @@ def main(): def commandPreparation(): # Direct command which triggers an additional step reply and one completion reply # Single Command Testing - # command = PUSTelecommand(service=17, subservice=1, SSC=21) + #command = PUSTelecommand(service=17, subservice=1, SSC=21) file = bytearray([1, 2, 3, 4, 5]) command = PUSTelecommand(service=23, subservice=1, SSC=21, data=file) command.packCommandTuple() @@ -143,6 +142,7 @@ def setUpSocket(): def setCommunicationInterface(tmtcPrinter): if g.comIF == 0: + setUpSocket() communicationInterface = EthernetComIF(tmtcPrinter, g.tmTimeout, g.tcSendTimeoutFactor, g.sockSend, g.sockReceive, g.sendAddress) else: diff --git a/comIF/OBSW_Serial_ComIF.py b/comIF/OBSW_Serial_ComIF.py index f612dd3e679df91c02e219bf8a138d5a2e7ee5a2..b428aff2ceac4eccb126695a97fd8a4fd5aecd11 100644 --- a/comIF/OBSW_Serial_ComIF.py +++ b/comIF/OBSW_Serial_ComIF.py @@ -10,7 +10,11 @@ class SerialComIF(CommunicationInterface): def __init__(self, tmtcPrinter, comPort, baudRate, serialTimeout): super().__init__(tmtcPrinter) self.tmtcPrinter = tmtcPrinter - self.serial = serial.Serial(port=comPort, baudrate=baudRate, timeout=serialTimeout) + try: + self.serial = serial.Serial(port=comPort, baudrate=baudRate, timeout=serialTimeout) + except serial.SerialException: + print("Serial Port can not be opened") + exit() self.data = bytearray() self.numberOfPackets = 0 # self.serial.open() diff --git a/tc/OBSW_TcService3.py b/tc/OBSW_TcService3.py index 777d2887540f22c32213c370bc9f3c9aab993284..19d18e309a674551b0c497bbb229241989a0063b 100644 --- a/tc/OBSW_TcService3.py +++ b/tc/OBSW_TcService3.py @@ -38,28 +38,30 @@ def packService3TestInto(tcQueue): tcQueue.put(("print", "\r\nTesting Service 3: Enable custom definition")) command = PUSTelecommand(service=3, subservice=5, SSC=3030, data=sid1) tcQueue.put(command.packCommandTuple()) - # enable custom diag definition - tcQueue.put(("print", "\r\nTesting Service 3: Enable custom diagnostics definition")) - command = PUSTelecommand(service=3, subservice=7, SSC=3030, data=sid1) - tcQueue.put(command.packCommandTuple()) - # enable gps0 - tcQueue.put(("print", "\r\nTesting Service 3: Enable GPS definition")) - command = PUSTelecommand(service=3, subservice=5, SSC=3030, data=sidGps) - tcQueue.put(command.packCommandTuple()) + # # enable custom diag definition + # tcQueue.put(("print", "\r\nTesting Service 3: Enable custom diagnostics definition")) + # command = PUSTelecommand(service=3, subservice=7, SSC=3030, data=sid1) + # tcQueue.put(command.packCommandTuple()) + # # enable gps0 + # tcQueue.put(("print", "\r\nTesting Service 3: Enable GPS definition")) + # command = PUSTelecommand(service=3, subservice=5, SSC=3030, data=sidGps) + # tcQueue.put(command.packCommandTuple()) # maybe wait a bit to receive at least 2 packets.. + tcQueue.put(("wait", 8)) + # Disable custom hk definition - tcQueue.put(("print", "\r\nTesting Service 3: Disable custom definition")) - command = PUSTelecommand(service=3, subservice=6, SSC=3030, data=sid1) - tcQueue.put(command.packCommandTuple()) + # tcQueue.put(("print", "\r\nTesting Service 3: Disable custom definition")) + # command = PUSTelecommand(service=3, subservice=6, SSC=3030, data=sid1) + # tcQueue.put(command.packCommandTuple()) # Disable custom diag definition - tcQueue.put(("print", "\r\nTesting Service 3: Disable custom diagnostics definition")) - command = PUSTelecommand(service=3, subservice=8, SSC=3030, data=sid1) - tcQueue.put(command.packCommandTuple()) - # disable gps0 - tcQueue.put(("print", "\r\nTesting Service 3: Disable GPS definition")) - command = PUSTelecommand(service=3, subservice=6, SSC=3030, data=sidGps) - tcQueue.put(command.packCommandTuple()) + # tcQueue.put(("print", "\r\nTesting Service 3: Disable custom diagnostics definition")) + # command = PUSTelecommand(service=3, subservice=8, SSC=3030, data=sid1) + # tcQueue.put(command.packCommandTuple()) + # # disable gps0 + # tcQueue.put(("print", "\r\nTesting Service 3: Disable GPS definition")) + # command = PUSTelecommand(service=3, subservice=6, SSC=3030, data=sidGps) + # tcQueue.put(command.packCommandTuple()) # report custom hk definition # report custom diag definition diff --git a/tm/OBSW_TmPacket.py b/tm/OBSW_TmPacket.py index 2806196c85fb8fd588e6d7ca0d2febb5b306a6f5..d37864dbfa0748939d738debac2415e94fd649b7 100644 --- a/tm/OBSW_TmPacket.py +++ b/tm/OBSW_TmPacket.py @@ -9,6 +9,7 @@ Author: R.Mueller, S. Gaisser from tm.OBSW_PusTm import PUSTelemetry from tm.OBSW_TmService1 import Service1TM from tm.OBSW_TmService3 import Service3TM +from tm.OBSW_TmService5 import Service5TM import struct # TM Packets use the generic space packet structure provided by OBSWPusPacket to generate individual # telemetry packets for all services @@ -50,49 +51,6 @@ class Service2TM(PUSTelemetry): return -class Service5TM(PUSTelemetry): - def __init__(self, byteArray): - super().__init__(byteArray) - self.printPacketInfo("Event") - if self.getSubservice() == 1: - self.appendPacketInfo(" Info") - elif self.getSubservice() == 2: - self.appendPacketInfo(" Error Low Severity") - elif self.getSubservice() == 3: - self.appendPacketInfo(" Error Med Severity") - elif self.getSubservice() == 4: - self.appendPacketInfo(" Error High Severity") - self.eventId = struct.unpack('>H', self.byteArrayData[0:2])[0] - self.objectId = struct.unpack('>I', self.byteArrayData[2:6])[0] - self.param1 = struct.unpack('>I', self.byteArrayData[6:10])[0] - self.param2 = struct.unpack('>I', self.byteArrayData[10:14])[0] - - def printTelemetryHeader(self, array): - super().printTelemetryHeader(array) - array.append(str(self.eventId)) - array.append(hex(self.objectId)) - array.append(str(self.param1)) - array.append(str(self.param2)) - - def printTelemetryColumnHeaders(self, array): - super().printTelemetryColumnHeaders(array) - array.append("Event ID") - array.append("Reporter ID") - array.append("Parameter 1") - array.append("Parameter 2") - - def packTmInformation(self): - tmInformation = super().packTmInformation() - addInformation = { - "RID": self.objectId, - "EventID": self.eventId, - "Param1": self.param1, - "Param2": self.param2 - } - tmInformation.update(addInformation) - return tmInformation - - class Service8TM(PUSTelemetry): def __init__(self, byteArray): super().__init__(byteArray) diff --git a/tm/OBSW_TmService1.py b/tm/OBSW_TmService1.py index 88119e3a84c9cd1a7244d7399d6f8ae90e79e61e..969aaa173c465adbbf43e545cd1f7add2527f0e2 100644 --- a/tm/OBSW_TmService1.py +++ b/tm/OBSW_TmService1.py @@ -30,7 +30,7 @@ class Service1TM(PUSTelemetry): self.errorParam1 = struct.unpack('>I', self.byteArrayData[7:11])[0] self.errorParam2 = struct.unpack('>I', self.byteArrayData[11:15])[0] else: - # self.printData() + self.printData() self.ErrCode = struct.unpack('>H', self.byteArrayData[4:6])[0] self.errorParam1 = struct.unpack('>I', self.byteArrayData[6:10])[0] self.errorParam2 = struct.unpack('>I', self.byteArrayData[10:14])[0] @@ -48,8 +48,8 @@ class Service1TM(PUSTelemetry): if self.isStep: array.append(str(self.stepNumber)) array.append(str(hex(self.ErrCode))) - array.append(str(hex(self.errorParam1))) - array.append(str(hex(self.errorParam2))) + array.append(str(hex(self.errorParam1)) + ", " + str(self.errorParam1)) + array.append(str(hex(self.errorParam2)) + ", " + str(self.errorParam2)) elif self.isStep: array.append(str(self.stepNumber)) @@ -77,4 +77,4 @@ class Service1TM(PUSTelemetry): tmInformation.update({"errCode": self.ErrCode}) if self.isStep: tmInformation.update({"stepNumber": self.ErrCode}) - return tmInformation \ No newline at end of file + return tmInformation diff --git a/tm/OBSW_TmService3.py b/tm/OBSW_TmService3.py index c40b1af485c7851c83abf5bd3d94d432b0ad9b4a..a3c9073ffb312ef0637bbd9de39cc3e848a27eb9 100644 --- a/tm/OBSW_TmService3.py +++ b/tm/OBSW_TmService3.py @@ -20,7 +20,7 @@ class Service3TM(PUSTelemetry): if self.getSubservice() == 25: 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 0x2f00: + 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"] @@ -50,6 +50,20 @@ class Service3TM(PUSTelemetry): self.hkContent.append(self.vx) self.hkContent.append(self.vy) self.hkContent.append(self.vz) + elif self.sid == 0x4300: + self.hkHeader = ["Bool", "UINT8", "UINT16", "UINT32", "FLOAT1", "FLOAT2"] + self.testBool = self.byteArrayData[4] + self.hkContent.append(self.testBool) + self.testUint8 = self.byteArrayData[5] + self.hkContent.append(self.testUint8) + self.testUint16 = (self.byteArrayData[6] << 8) | self.byteArrayData[7] + self.hkContent.append(self.testUint16) + self.testUint32 = struct.unpack('>I', self.byteArrayData[7:11])[0] + self.hkContent.append(self.testUint32) + self.floatVector1 = struct.unpack('>f', self.byteArrayData[11:15])[0] + self.hkContent.append(self.floatVector1) + self.floatVector2 = struct.unpack('>f', self.byteArrayData[15:19])[0] + self.hkContent.append(self.floatVector2) def printTelemetryHeader(self, array): super().printTelemetryHeader(array) @@ -60,5 +74,5 @@ class Service3TM(PUSTelemetry): def printTelemetryColumnHeaders(self, array): super().printTelemetryColumnHeaders(array) array.append("SID") - array.append("Number of Parameters") + array.append("HK Data Size") return diff --git a/tm/OBSW_TmService5.py b/tm/OBSW_TmService5.py new file mode 100644 index 0000000000000000000000000000000000000000..8dd25e2f80777cd47d8ca6c5587b6376248ed26c --- /dev/null +++ b/tm/OBSW_TmService5.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +""" +Program: OBSW_TmService5.py +Date: 30.12.2019 +Description: Deserialize PUS Event Report +Author: R. Mueller +""" + +from tm.OBSW_PusTm import PUSTelemetry +import struct + + +class Service5TM(PUSTelemetry): + def __init__(self, byteArray): + super().__init__(byteArray) + self.printPacketInfo("Event") + if self.getSubservice() == 1: + self.appendPacketInfo(" Info") + elif self.getSubservice() == 2: + self.appendPacketInfo(" Error Low Severity") + elif self.getSubservice() == 3: + self.appendPacketInfo(" Error Med Severity") + elif self.getSubservice() == 4: + self.appendPacketInfo(" Error High Severity") + self.eventId = struct.unpack('>H', self.byteArrayData[0:2])[0] + self.objectId = struct.unpack('>I', self.byteArrayData[2:6])[0] + self.param1 = struct.unpack('>I', self.byteArrayData[6:10])[0] + self.param2 = struct.unpack('>I', self.byteArrayData[10:14])[0] + + def printTelemetryHeader(self, array): + super().printTelemetryHeader(array) + array.append(str(self.eventId)) + array.append(hex(self.objectId)) + array.append(str(hex(self.param1)) + ", " + str(self.param1)) + array.append(str(hex(self.param2)) + ", " + str(self.param2)) + + def printTelemetryColumnHeaders(self, array): + super().printTelemetryColumnHeaders(array) + array.append("Event ID") + array.append("Reporter ID") + array.append("Parameter 1") + array.append("Parameter 2") + + def packTmInformation(self): + tmInformation = super().packTmInformation() + addInformation = { + "RID": self.objectId, + "EventID": self.eventId, + "Param1": self.param1, + "Param2": self.param2 + } + tmInformation.update(addInformation) + return tmInformation diff --git a/utility/OBSW_TmTcPrinter.py b/utility/OBSW_TmTcPrinter.py index 88e0f8d0f7857f6f4c542820215e15c4b762de23..297c6c97d04a41fc8e0d1d1860c4c884c3dcd581 100644 --- a/utility/OBSW_TmTcPrinter.py +++ b/utility/OBSW_TmTcPrinter.py @@ -28,7 +28,7 @@ class TmtcPrinter: self.handleLongPrint(packet) self.handleWiretappingPacket(packet) self.handleDataReplyPacket(packet) - if packet.getService == 3 and packet.getSubservice == 25 or 26: + if packet.getService == 3 and (packet.getSubservice == 25 or packet.getSubservice == 26): self.handleHkPrint(packet) if g.printRawTmData: self.printBuffer = "TM Data:" + "\n" + self.returnDataString(packet.data)