From 28b9386af9b8760d85b8f7c7e8f424d8e3ec9741 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Sun, 6 Sep 2020 19:11:25 +0200
Subject: [PATCH] initializations moved to ctor, gotta find better solution

---
 obsw_tmtc_client.py | 19 ++++++++++---------
 tmtc_core           |  2 +-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py
index 4924068..02ed4b5 100755
--- a/obsw_tmtc_client.py
+++ b/obsw_tmtc_client.py
@@ -118,21 +118,20 @@ class TmTcHandler:
         # This flag could be used later to command the TMTC Client with a front-end
         self.command_received = True
         self.tmtc_printer = TmTcPrinter(g.G_DISPLAY_MODE, g.G_PRINT_TO_FILE, True)
-        self.communication_interface = None
-        self.tm_listener = None
+        self.communication_interface = set_communication_interface(self.tmtc_printer)
+        self.tm_listener = TmListener(
+            com_interface=self.communication_interface, tm_timeout=g.G_TM_TIMEOUT,
+            tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR
+        )
         self.initialize_com_if_and_listener()
         atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface)
 
     def initialize_com_if_and_listener(self):
-        self.communication_interface = set_communication_interface(self.tmtc_printer)
-        if self.communication_interface is None:
+        if not self.communication_interface.valid:
             LOGGER.info("No communication interface set for now")
             LOGGER.info("TM listener will not be started")
             return
-        self.tm_listener = TmListener(
-            com_interface=self.communication_interface, tm_timeout=g.G_TM_TIMEOUT,
-            tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR
-        )
+
         self.tm_listener.start()
 
     def perform_operation(self):
@@ -168,7 +167,9 @@ class TmTcHandler:
             if self.tm_listener.event_reply_received.is_set():
                 LOGGER.info("TmTcHandler: Packets received.")
                 self.tmtc_printer.print_telemetry_queue(self.tm_listener.retrieve_tm_packet_queue())
-                self.command_received = True
+                self.tm_listener.clear_tm_packet_queue()
+                self.tm_listener.event_reply_received.clear()
+            self.command_received = True
 
         elif self.mode == g.ModeList.SingleCommandMode:
             pus_packet_tuple = command_preparation()
diff --git a/tmtc_core b/tmtc_core
index 7314ea0..66da7ab 160000
--- a/tmtc_core
+++ b/tmtc_core
@@ -1 +1 @@
-Subproject commit 7314ea01cc62f8513f4310f96286e667399145ba
+Subproject commit 66da7ab3912f96494b6011f22738d1750149cd44
-- 
GitLab