From 0e527c8a4e847d7e25150c164c4bb977eb9e5034 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Sun, 12 Jan 2020 14:17:31 +0100
Subject: [PATCH] Service 3 testing continued

---
 ...l => OBSW_TmTcClient_Unit_Test_Serial.xml} |  6 +--
 ...SW_TmTc_Client_Service_17_Test_Serial.xml} |  4 +-
 .../OBSW_MultipleCommandsSenderReceiver.py    |  7 ++--
 tc/OBSW_TcService3.py                         | 37 ++++++++++++++-----
 test/OBSW_UnitTest.py                         |  2 +-
 5 files changed, 37 insertions(+), 19 deletions(-)
 rename .idea/runConfigurations/{OBSW_UdpClient_Unit_Test_Serial.xml => OBSW_TmTcClient_Unit_Test_Serial.xml} (73%)
 rename .idea/runConfigurations/{OBSW_UdpClient_Service_17_Test_Serial.xml => OBSW_TmTc_Client_Service_17_Test_Serial.xml} (77%)

diff --git a/.idea/runConfigurations/OBSW_UdpClient_Unit_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
similarity index 73%
rename from .idea/runConfigurations/OBSW_UdpClient_Unit_Test_Serial.xml
rename to .idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
index 693c841..3b98824 100644
--- a/.idea/runConfigurations/OBSW_UdpClient_Unit_Test_Serial.xml
+++ b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="OBSW_UdpClient Unit Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="OBSW_TmTcClient Unit Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
@@ -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 5 -p -c 1" />
+    <option name="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" />
+    <option name="PARAMETERS" value="-m 5 -p -c 1 --COM COM9" />
     <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_Service_17_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml
similarity index 77%
rename from .idea/runConfigurations/OBSW_UdpClient_Service_17_Test_Serial.xml
rename to .idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml
index 52ef5e5..0dd68ef 100644
--- a/.idea/runConfigurations/OBSW_UdpClient_Service_17_Test_Serial.xml
+++ b/.idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="OBSW_UdpClient Service 17 Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="OBSW_TmTc Client Service 17 Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
@@ -12,7 +12,7 @@
     <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="SCRIPT_NAME" value="$PROJECT_DIR$/OBSW_TmTcClient.py" />
     <option name="PARAMETERS" value="-m 3 -s 17 -c 1 -p" />
     <option name="SHOW_COMMAND_LINE" value="false" />
     <option name="EMULATE_TERMINAL" value="true" />
diff --git a/sendreceive/OBSW_MultipleCommandsSenderReceiver.py b/sendreceive/OBSW_MultipleCommandsSenderReceiver.py
index 6fcac71..7f4180e 100644
--- a/sendreceive/OBSW_MultipleCommandsSenderReceiver.py
+++ b/sendreceive/OBSW_MultipleCommandsSenderReceiver.py
@@ -53,7 +53,8 @@ class MultipleCommandSenderReceiver(SequentialCommandSenderReceiver):
     def sendAllQueue(self):
         while not self.tcQueue.empty():
             if g.comIF == 1:
-                time.sleep(0.01)  # pause could be smaller, but causes overrun error on flashed board
+                pass
+                # time.sleep(0.01)  # pause could be smaller, but causes overrun error on flashed board
             self.sendAndPrintTc()
 
     def sendAndPrintTc(self):
@@ -92,9 +93,9 @@ class MultipleCommandSenderReceiver(SequentialCommandSenderReceiver):
 
     def handleLastRepliesListening(self, start_time):
         elapsed_time_seconds = 0
-        while elapsed_time_seconds < self.tmTimeout:
+        while elapsed_time_seconds < self.tmTimeout/2.0:
             elapsed_time_seconds = time.time() - start_time
-            tmReady = self.comInterface.dataAvailable(self.tmTimeout/2.0)
+            tmReady = self.comInterface.dataAvailable(self.tmTimeout/4.0)
             if tmReady:
                 self.receiveTelemetryAndStoreInformation()
 
diff --git a/tc/OBSW_TcService3.py b/tc/OBSW_TcService3.py
index f8ed0d0..777d288 100644
--- a/tc/OBSW_TcService3.py
+++ b/tc/OBSW_TcService3.py
@@ -33,21 +33,41 @@ def packService3TestInto(tcQueue):
     tcQueue.put(("print", "\r\nTesting Service 3: Adding custom diganostics definition"))
     command = PUSTelecommand(service=3, subservice=2, SSC=3020, data=hkDefinition2)
     tcQueue.put(command.packCommandTuple())
+
     # enable custom hk definition
     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 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
-    # disable custom hk definition
-    # disable 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..
+    # 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())
+    # 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())
+
     # report custom hk definition
     # report custom diag definition
+    # report gps0 definition
+
     # generate one custom hk definition
     # generate one custom diag definition
+    # generate one gps 0 definition
     # modify custom hk definition interval
     # modify custom diag definition interval
     # report custom hk definition
@@ -58,10 +78,7 @@ def packService3TestInto(tcQueue):
     # report custom diag definition
     # delete custom hk definition
     # delete custom diag definition
-    # 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: Deleting custom HK definition"))
     # command = PUSTelecommand(service=3, subservice=3, SSC=3080, data=sid1)
     # tcQueue.put(command.packCommandTuple())
diff --git a/test/OBSW_UnitTest.py b/test/OBSW_UnitTest.py
index 1563356..e42e262 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.2, 1.5, 1.5]
+        cls.waitTime = [1.5, 1.5, 1.5]
         packService5TestInto(cls.testQueue)
 
     def test_Service5(self):
-- 
GitLab