From abcc41a1863b9334324c00dc9f2e8f330c3bb231 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Thu, 16 Apr 2020 12:02:07 +0200
Subject: [PATCH] some bugfixes

---
 .../OBSW_TmTcClient_Service_2_Serial.xml      |  2 +-
 .../OBSW_TmTcClient_Unit_Test_Serial.xml      |  2 +-
 sendreceive/obsw_command_sender_receiver.py   |  2 +-
 .../obsw_multiple_commands_sender_receiver.py | 34 +++++++++----------
 test/obsw_module_test.py                      |  6 ++--
 utility/obsw_tmtc_printer.py                  | 17 +++++-----
 6 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/.idea/runConfigurations/OBSW_TmTcClient_Service_2_Serial.xml b/.idea/runConfigurations/OBSW_TmTcClient_Service_2_Serial.xml
index c32ca7a..b6ff584 100644
--- a/.idea/runConfigurations/OBSW_TmTcClient_Service_2_Serial.xml
+++ b/.idea/runConfigurations/OBSW_TmTcClient_Service_2_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_tmtc_client.py" />
-    <option name="PARAMETERS" value="-m 3 -s 2 -p -c 1" />
+    <option name="PARAMETERS" value="-m 3 -s 2 -c 1 --COM /dev/ttyUSB1" />
     <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_TmTcClient_Unit_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
index 1a7ced3..7d146a9 100644
--- a/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
+++ b/.idea/runConfigurations/OBSW_TmTcClient_Unit_Test_Serial.xml
@@ -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_tmtc_client.py" />
+    <option name="SCRIPT_NAME" value="$PROJECT_DIR$/obsw_tmtc_client.py" />
     <option name="PARAMETERS" value="-m 5 -c 1 --hk" />
     <option name="SHOW_COMMAND_LINE" value="false" />
     <option name="EMULATE_TERMINAL" value="true" />
diff --git a/sendreceive/obsw_command_sender_receiver.py b/sendreceive/obsw_command_sender_receiver.py
index 3e71394..6de785f 100644
--- a/sendreceive/obsw_command_sender_receiver.py
+++ b/sendreceive/obsw_command_sender_receiver.py
@@ -109,7 +109,7 @@ class CommandSenderReceiver:
             self._tmtc_printer.print_string(print_string)
         elif queue_entry_first == "export":
             export_name = queue_entry_second
-            self._tmtc_printer.print_to_file(export_name, True)
+            self._tmtc_printer.print_to_file(export_name, False)
         elif queue_entry_first == "timeout":
             self._tm_timeout = queue_entry_second
         else:
diff --git a/sendreceive/obsw_multiple_commands_sender_receiver.py b/sendreceive/obsw_multiple_commands_sender_receiver.py
index 77b38a3..c3b7652 100644
--- a/sendreceive/obsw_multiple_commands_sender_receiver.py
+++ b/sendreceive/obsw_multiple_commands_sender_receiver.py
@@ -23,26 +23,26 @@ class MultipleCommandSenderReceiver(SequentialCommandSenderReceiver):
     Wait intervals can be specified with wait time between the send bursts.
     This is generally done in the separate test classes in UnitTest
     """
-    def __init__(self, comInterface: CommunicationInterface, tmtcPrinter: TmTcPrinter,
-                 tcQueue: Deque, tmListener: TmListenerT, waitIntervals: list,
-                 waitTime: Union[float, list], printTm: bool):
+    def __init__(self, com_interface: CommunicationInterface, tmtc_printer: TmTcPrinter,
+                 tc_queue: Deque, tm_listener: TmListenerT, wait_intervals: list,
+                 wait_time: Union[float, list], print_tm: bool):
         """
         TCs are sent in burst when applicable. Wait intervals can be specified by supplying
         respective arguments
-        :param comInterface:
-        :param tmtcPrinter:
-        :param tcQueue:
-        :param waitIntervals: List of pause intervals. For example [1,3] means that a wait_time
+        :param com_interface:
+        :param tmtc_printer:
+        :param tc_queue:
+        :param wait_intervals: List of pause intervals. For example [1,3] means that a wait_time
             is applied after
         sendinf the first and the third telecommand
-        :param waitTime: List of wait times or uniform wait time as float
-        :param printTm:
+        :param wait_time: List of wait times or uniform wait time as float
+        :param print_tm:
         """
-        super().__init__(com_interface=comInterface, tmtc_printer=tmtcPrinter,
-                         tm_listener=tmListener, tc_queue=tcQueue)
-        self.waitIntervals = waitIntervals
-        self.waitTime = waitTime
-        self.printTm = printTm
+        super().__init__(com_interface=com_interface, tmtc_printer=tmtc_printer,
+                         tm_listener=tm_listener, tc_queue=tc_queue)
+        self.waitIntervals = wait_intervals
+        self.waitTime = wait_time
+        self.printTm = print_tm
         self.tmInfoQueue = deque()
         self.tcInfoQueue = deque()
         self.pusPacketInfo = []
@@ -68,7 +68,7 @@ class MultipleCommandSenderReceiver(SequentialCommandSenderReceiver):
 
     def __handle_tc_resending(self):
         while not self.__all_replies_received:
-            if self._tc_queue.empty():
+            if self._tc_queue.__len__ == 0:
                 if self._start_time == 0:
                     self._start_time = time.time()
             self._check_for_timeout()
@@ -104,10 +104,10 @@ class MultipleCommandSenderReceiver(SequentialCommandSenderReceiver):
         self._tm_listener.tmInfoQueue.clear()
 
     @staticmethod
-    def wait_for_last_replies_listening(waitTime: float):
+    def wait_for_last_replies_listening(wait_time: float):
         elapsed_time_seconds = 0
         start_time = time.time()
-        while elapsed_time_seconds < waitTime:
+        while elapsed_time_seconds < wait_time:
             elapsed_time_seconds = time.time() - start_time
 
 
diff --git a/test/obsw_module_test.py b/test/obsw_module_test.py
index 3223607..e194aef 100644
--- a/test/obsw_module_test.py
+++ b/test/obsw_module_test.py
@@ -88,9 +88,9 @@ class TestService(unittest.TestCase):
         :return:
         """
         module_tester = MultipleCommandSenderReceiver(
-            comInterface=self.communication_interface, tmtcPrinter=self.tmtc_printer,
-            tmListener=self.tm_listener, tcQueue=self.test_queue, waitIntervals=self.wait_intervals,
-            waitTime=self.wait_time, printTm=g.G_PRINT_RAW_TM)
+            com_interface=self.communication_interface, tmtc_printer=self.tmtc_printer,
+            tm_listener=self.tm_listener, tc_queue=self.test_queue, wait_intervals=self.wait_intervals,
+            wait_time=self.wait_time, print_tm=g.G_PRINT_RAW_TM)
         (tc_info_queue, tm_info_queue) = module_tester.send_tc_queue_and_return_info()
         assertion_dict = self._analyse_tm_tc_info(tm_info_queue, tc_info_queue)
         return assertion_dict
diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py
index 50593b1..c28a4e2 100644
--- a/utility/obsw_tmtc_printer.py
+++ b/utility/obsw_tmtc_printer.py
@@ -23,19 +23,19 @@ class TmTcPrinter:
     """
     This class handles printing to the command line and to files.
     """
-    def __init__(self, displayMode: str = "long", doPrintToFile: bool = False,
-                 printTc: bool = True):
+    def __init__(self, display_mode: str = "long", do_print_to_file: bool = True,
+                 print_tc: bool = True):
         """
-        :param displayMode: "long" or "short" TODO: replace by enum
-        :param doPrintToFile: if true, print to file
-        :param printTc: if true, print TCs
+        :param display_mode: "long" or "short" TODO: replace by enum
+        :param do_print_to_file: if true, print to file
+        :param print_tc: if true, print TCs
         """
         self.print_buffer = ""
         # global print buffer which will be useful to print something to file
         self.file_buffer = ""
-        self.display_mode = displayMode
-        self.do_print_to_file = doPrintToFile
-        self.print_tc = printTc
+        self.display_mode = display_mode
+        self.do_print_to_file = do_print_to_file
+        self.print_tc = print_tc
 
     def print_telemetry(self, packet: PusTelemetry):
         """
@@ -199,6 +199,7 @@ class TmTcPrinter:
         str_to_print = "["
         for byte in byte_array:
             str_to_print += str(hex(byte)) + " , "
+        str_to_print = str_to_print.rstrip(' ')
         str_to_print = str_to_print.rstrip(',')
         str_to_print += ']'
         return str_to_print
-- 
GitLab