diff --git a/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml index 3b988241761cf6dc92e2e4b86f0ca3c60f5ed4b9..8b397ef55f760aad99df42331dd0cedf44d3fbe9 100644 --- a/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml +++ b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml @@ -13,7 +13,7 @@ <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" /> - <option name="PARAMETERS" value="-m 5 -p -c 1 --COM COM9" /> + <option name="PARAMETERS" value="-m 5 -p -c 1" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> <option name="MODULE_MODE" value="false" /> diff --git a/.idea/runConfigurations/OBSW_UdpClient_GPS0_Serial.xml b/.idea/runConfigurations/OBSW_UdpClient_GPS0_Serial.xml index ec3c40e20f61a7da5a98c019bb18df99298c225f..ba1c3707892750476f676e3e2e6dae06a8b7acf4 100644 --- a/.idea/runConfigurations/OBSW_UdpClient_GPS0_Serial.xml +++ b/.idea/runConfigurations/OBSW_UdpClient_GPS0_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 GPS0 -c 1" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" /> + <option name="PARAMETERS" value="-m 3 -s GPS0 -c 1 --hk -p" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> <option name="MODULE_MODE" value="false" /> diff --git a/OBSW_TmTcClient.py b/OBSW_TmTcClient.py index ed17d8d3925a11dc1fced865d386c0f1a028c1ba..ca7def3309c794df6ea73bb6e127f2c569f790d8 100644 --- a/OBSW_TmTcClient.py +++ b/OBSW_TmTcClient.py @@ -74,10 +74,9 @@ from comIF.OBSW_Serial_ComIF import SerialComIF def main(): args = parseInputArguments() setGlobals(args) - atexit.register(g.keyboardInterruptHandler) tmtcPrinter = TmtcPrinter(g.displayMode, g.printToFile, True) communicationInterface = setCommunicationInterface(tmtcPrinter) - + atexit.register(communicationInterface.keyboardInterruptHandler) if g.modeId == "ListenerMode": Receiver = CommandSenderReceiver(communicationInterface, tmtcPrinter, g.tmTimeout, g.tcSendTimeoutFactor, g.printToFile) diff --git a/comIF/OBSW_ComInterface.py b/comIF/OBSW_ComInterface.py index cc519f99e4a79a2d80f42e0ea44a9bd1c2de425e..6fcc7a4bf381e598985b3efdf5c85b0750002291 100644 --- a/comIF/OBSW_ComInterface.py +++ b/comIF/OBSW_ComInterface.py @@ -8,7 +8,7 @@ Description: Generic Communication Interface. Defines the syntax of the communic @author: R. Mueller """ from abc import abstractmethod - +import config.OBSW_Config as g class CommunicationInterface: def __init__(self, tmtcPrinter): @@ -48,5 +48,12 @@ class CommunicationInterface: def receiveTelemetryAndStoreTuple(self, tmTupleQueue): pass + def keyboardInterruptHandler(self): + print("Disconnect registered") + # Unit Test closes Serial Port at the end + if g.modeId != "OBSWUnitTest": + disconnect = bytearray([0, 0, 0, 0, 0]) + self.sendTelecommand(disconnect) + diff --git a/config/OBSW_Config.py b/config/OBSW_Config.py index d28b9cfc8e6e1685b88d1867711820f84557b5eb..33154c9e37ec87f91af9bec19d521a7daf3947c5 100644 --- a/config/OBSW_Config.py +++ b/config/OBSW_Config.py @@ -91,9 +91,3 @@ def setGlobals(args): displayMode = displayMode service = service printToFile = args.printFile - - -def keyboardInterruptHandler(): - print("Disconnect registered") - disconnect = bytearray([0, 0, 0, 0, 0]) - sockSend.sendto(disconnect, sendAddress) diff --git a/sendreceive/OBSW_CommandSenderReceiver.py b/sendreceive/OBSW_CommandSenderReceiver.py index 0efbee77e6663c17cf560d4189fb17748cf99290..70f52d8b2eb9414df2ff6a1dfdc43611360cd239 100644 --- a/sendreceive/OBSW_CommandSenderReceiver.py +++ b/sendreceive/OBSW_CommandSenderReceiver.py @@ -119,4 +119,3 @@ def connectToBoard(): # send multiple times to get connection if there are problems - diff --git a/tc/OBSW_TcPacker.py b/tc/OBSW_TcPacker.py index 34ca200848735f224eef5bbda59b3ba14ea67a3f..5d8d8105f872d996024a518d504d91a128566b40 100644 --- a/tc/OBSW_TcPacker.py +++ b/tc/OBSW_TcPacker.py @@ -145,26 +145,46 @@ def packDummyDeviceTestInto(tcQueue): def packGpsTestInto(objectId, tcQueue): - tcQueue.put(("print", "Testing GPS Device")) + if bytes(objectId).hex() == "44001f00": + gpsString = "GPS0" + elif bytes(objectId).hex() == "44002000": + gpsString = "GPS1" + tcQueue.put(("print", "Testing " + gpsString + " Device")) # Set Mode Off - tcQueue.put(("print", "\n\rTesting GPS: Set Off")) + tcQueue.put(("print", "\n\rTesting " + gpsString + ": Set Off")) modeData = packModeData(objectId, 0, 0) command = PUSTelecommand(service=200, subservice=1, SSC=11, data=modeData) tcQueue.put(command.packCommandTuple()) # Set Mode On - tcQueue.put(("print", "\n\rTesting GPS: Set On")) + tcQueue.put(("print", "\n\rTesting " + gpsString + ": Set On")) modeData = packModeData(objectId, 1, 0) command = PUSTelecommand(service=200, subservice=1, SSC=12, data=modeData) tcQueue.put(command.packCommandTuple()) + # Enable HK report + sidGps = 0 + if objectId == bytearray([0x44, 0x00, 0x1F, 0x00]): + sidGps = bytearray([0x00, 0x00, 0x1f, 0x00]) + tcQueue.put(("print", "\r\nTesting " + gpsString + ": Enable HK Reporting")) + command = PUSTelecommand(service=3, subservice=5, SSC=13, data=sidGps) + tcQueue.put(command.packCommandTuple()) + elif objectId == bytearray([0x44, 0x00, 0x20, 0x00]): + sidGps = bytearray([0x00, 0x00, 0x2f, 0x00]) + tcQueue.put(("print", "\r\nTesting " + gpsString + ": Enable HK Reporting")) + command = PUSTelecommand(service=3, subservice=5, SSC=14, data=sidGps) + tcQueue.put(command.packCommandTuple()) # pack wait interval until mode is on and a few gps replies have been received tcQueue.put(("wait", 5)) + # Disable HK reporting + tcQueue.put(("print", "\r\nTesting Service 3: Disable " + gpsString + " definition")) + command = PUSTelecommand(service=3, subservice=6, SSC=15, data=sidGps) + tcQueue.put(command.packCommandTuple()) # Set Mode Off - tcQueue.put(("print", "\n\rTesting GPS: Set Off")) + tcQueue.put(("print", "\n\rTesting " + gpsString + ": Set Off")) modeData = packModeData(objectId, 0, 0) command = PUSTelecommand(service=200, subservice=1, SSC=13, data=modeData) tcQueue.put(command.packCommandTuple()) tcQueue.put(("print", "\r")) - tcQueue.put(("export", "log/tmtc_log_service_gps.txt")) + tcQueue.put(("export", "log/tmtc_log_service_" + gpsString + ".txt")) return tcQueue diff --git a/tc/OBSW_TcService3.py b/tc/OBSW_TcService3.py index 861c1165e5a9816a67af8d25c950bf648b276f0a..4f145bf7aeb22e541ae1512250f00601e7bab4da 100644 --- a/tc/OBSW_TcService3.py +++ b/tc/OBSW_TcService3.py @@ -70,32 +70,47 @@ def packService3TestInto(tcQueue): tcQueue.put(("print", "\r\nTesting Service 3: Disable GPS definition")) command = PUSTelecommand(service=3, subservice=6, SSC=3080, data=sidGps) tcQueue.put(command.packCommandTuple()) - - # report custom hk definition, 10 hk, 12 diagnostics - # report custom HK definition - tcQueue.put(("print", "\r\nTesting Service 3: Reporting pre-defined HK definition")) - command = PUSTelecommand(service=3, subservice=9, SSC=3000, data=sid1) - tcQueue.put(command.packCommandTuple()) # report custom Diag definition tcQueue.put(("print", "\r\nTesting Service 3: Reporting diag definition")) - command = PUSTelecommand(service=3, subservice=11, SSC=3000, data=sid2) + command = PUSTelecommand(service=3, subservice=11, SSC=3100, data=sid2) tcQueue.put(command.packCommandTuple()) # report gps definition - tcQueue.put(("print", "\r\nTesting Service 3: Reporting diag definition")) - command = PUSTelecommand(service=3, subservice=9, SSC=3000, data=sidGps) + tcQueue.put(("print", "\r\nTesting Service 3: Reporting GPS definition")) + command = PUSTelecommand(service=3, subservice=9, SSC=3110, data=sidGps) tcQueue.put(command.packCommandTuple()) # generate one custom hk definition + tcQueue.put(("print", "\r\nTesting Service 3: Generate one custom hk definition")) + command = PUSTelecommand(service=3, subservice=27, SSC=3120, data=sid1) + tcQueue.put(command.packCommandTuple()) # generate one custom diag definition + tcQueue.put(("print", "\r\nTesting Service 3: Generate one custom diagnostics definition")) + command = PUSTelecommand(service=3, subservice=28, SSC=3120, data=sid2) + tcQueue.put(command.packCommandTuple()) # generate one gps 0 definition + tcQueue.put(("print", "\r\nTesting Service 3: Generate one gps 0 defintion")) + command = PUSTelecommand(service=3, subservice=27, SSC=3120, data=sidGps) + tcQueue.put(command.packCommandTuple()) # modify custom hk definition interval + newInterval = struct.pack('>f', 10.0) + newIntervalCommand = sid1 + newInterval + tcQueue.put(("print", "\r\nTesting Service 3: Changing pre-defined HK definition interval")) + command = PUSTelecommand(service=3, subservice=31, SSC=3090, data=newIntervalCommand) + tcQueue.put(command.packCommandTuple()) + # report custom HK definition + tcQueue.put(("print", "\r\nTesting Service 3: Reporting pre-defined HK definition with changed interval")) + command = PUSTelecommand(service=3, subservice=9, SSC=3090, data=sid1) + tcQueue.put(command.packCommandTuple()) # modify custom diag definition interval - # report custom hk definition + newIntervalCommand = sid2 + newInterval + tcQueue.put(("print", "\r\nTesting Service 3: Changing custom diag HK definition interval")) + command = PUSTelecommand(service=3, subservice=32, SSC=3090, data=newIntervalCommand) + tcQueue.put(command.packCommandTuple()) # report custom diag definition + tcQueue.put(("print", "\r\nTesting Service 3: Reporting diag definition")) + command = PUSTelecommand(service=3, subservice=11, SSC=3100, data=sid2) + tcQueue.put(command.packCommandTuple()) # append parameter to custom hk definiton # append parameter to custom diag definition - # report custom hk definition - # report custom diag definition - # delete custom hk definition # delete custom diag definition tcQueue.put(("print", "\r\nTesting Service 3: Deleting custom diagnostics definition")) diff --git a/test/OBSW_UnitTest.py b/test/OBSW_UnitTest.py index e42e2620682d68414dc7e0e1fb8c0c06718d2dc3..698fa3f0c9aeb9144272bfbaa0f2e437628eb485 100644 --- a/test/OBSW_UnitTest.py +++ b/test/OBSW_UnitTest.py @@ -178,7 +178,7 @@ class TestService5(TestService): super().setUpClass() print("Testing Service 5") cls.waitIntervals = [1, 2, 3] - cls.waitTime = [1.5, 1.5, 1.5] + cls.waitTime = [1.5, 2.0, 2.0] packService5TestInto(cls.testQueue) def test_Service5(self):