From 9e812a3c4819aba68c5c2122e6b69e0a14f141af Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Wed, 22 Apr 2020 01:01:53 +0200
Subject: [PATCH] various bugfixes and improvements

---
 .../runConfigurations/OBSW_TmTcClient_Service_3_Serial_.xml | 2 +-
 tc/obsw_pus_tc_packer.py                                    | 5 +++--
 tm/obsw_tm_service_3.py                                     | 6 +++---
 utility/obsw_tmtc_printer.py                                | 5 ++++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/.idea/runConfigurations/OBSW_TmTcClient_Service_3_Serial_.xml b/.idea/runConfigurations/OBSW_TmTcClient_Service_3_Serial_.xml
index fdc43dd..642285d 100644
--- a/.idea/runConfigurations/OBSW_TmTcClient_Service_3_Serial_.xml
+++ b/.idea/runConfigurations/OBSW_TmTcClient_Service_3_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 3 -p -c 1 -t 4 --hk" />
+    <option name="PARAMETERS" value="-m 3 -s 3 -c 1 -t 3 --hk" />
     <option name="SHOW_COMMAND_LINE" value="false" />
     <option name="EMULATE_TERMINAL" value="false" />
     <option name="MODULE_MODE" value="false" />
diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py
index ba8da56..0df207e 100644
--- a/tc/obsw_pus_tc_packer.py
+++ b/tc/obsw_pus_tc_packer.py
@@ -206,12 +206,13 @@ def create_total_tc_queue() -> TcQueueT:
         os.mkdir("log")
     tc_queue = deque()
     tc_queue = pack_service2_test_into(tc_queue)
+    tc_queue = pack_service3_test_into(tc_queue)
     tc_queue = pack_service5_test_into(tc_queue)
     tc_queue = pack_service8_test_into(tc_queue)
     tc_queue = pack_service9_test_into(tc_queue)
     tc_queue = pack_service17_test_into(tc_queue)
     tc_queue = pack_service200_test_into(tc_queue)
     tc_queue = pack_dummy_device_test_into(tc_queue)
-    # objectId = bytearray([0x44, 0x00, 0x1F, 0x00])
-    # tc_queue = packGpsTestInto(objectId, tc_queue)
+    object_id = g.GPS0_ObjectId
+    tc_queue = pack_gps_test_into(object_id, tc_queue)
     return tc_queue
diff --git a/tm/obsw_tm_service_3.py b/tm/obsw_tm_service_3.py
index b942623..0a62a17 100644
--- a/tm/obsw_tm_service_3.py
+++ b/tm/obsw_tm_service_3.py
@@ -14,9 +14,9 @@ PusTm3T = TypeVar('PusTm3T', bound='Service3TM')
 
 
 class Service3TM(PusTelemetry):
-    def __init__(self, byteArray):
-        super().__init__(byteArray)
-        print("Length of _tm_data: " + str(len(self._tm_data)))
+    def __init__(self, byte_array: bytes):
+        super().__init__(byte_array)
+        print("Length of TM data: " + str(len(self._tm_data)))
         self.sid = struct.unpack('>I', self._tm_data[0:4])[0]
         self.hkHeader = []
         self.hkContent = []
diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py
index ec06146..e8ba7b0 100644
--- a/utility/obsw_tmtc_printer.py
+++ b/utility/obsw_tmtc_printer.py
@@ -147,14 +147,17 @@ class TmTcPrinter:
         :return:
         """
         self.print_buffer = "["
+        counter = 0
         for index, byte in enumerate(validity_buffer):
             for bit in range(1, 9):
                 if self.bit_extractor(byte, bit) == 1:
                     self.print_buffer = self.print_buffer + "Yes"
                 else:
                     self.print_buffer = self.print_buffer + "No"
-                if index == number_of_parameters:
+                counter += 1
+                if counter == number_of_parameters:
                     self.print_buffer = self.print_buffer + "]"
+                    break
                 else:
                     self.print_buffer = self.print_buffer + ", "
         print(self.print_buffer)
-- 
GitLab