From 2db647c0db42a003fba7f6537a07779438d63b64 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Mon, 27 Jan 2020 00:44:08 +0100 Subject: [PATCH] Service 3 + GPS test extended --- .../OBSW_TmTcClient_Unit_Test_Serial.xml | 2 +- .../OBSW_UdpClient_GPS0_Serial.xml | 4 +- OBSW_TmTcClient.py | 3 +- comIF/OBSW_ComInterface.py | 9 +++- config/OBSW_Config.py | 6 --- sendreceive/OBSW_CommandSenderReceiver.py | 1 - tc/OBSW_TcPacker.py | 30 +++++++++++--- tc/OBSW_TcService3.py | 41 +++++++++++++------ test/OBSW_UnitTest.py | 2 +- 9 files changed, 66 insertions(+), 32 deletions(-) diff --git a/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml index 3b98824..8b397ef 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 ec3c40e..ba1c370 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 ed17d8d..ca7def3 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 cc519f9..6fcc7a4 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 d28b9cf..33154c9 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 0efbee7..70f52d8 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 34ca200..5d8d810 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 861c116..4f145bf 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 e42e262..698fa3f 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): -- GitLab