From 4a37bedbea749a08bed102ab0c58073bb68db16d Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Thu, 21 May 2020 18:24:28 +0200
Subject: [PATCH] added print function to tm creator

---
 tm/obsw_pus_tm_creator.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tm/obsw_pus_tm_creator.py b/tm/obsw_pus_tm_creator.py
index 48d8483..46370f0 100644
--- a/tm/obsw_pus_tm_creator.py
+++ b/tm/obsw_pus_tm_creator.py
@@ -7,13 +7,12 @@ from tm.obsw_pus_tm_base import PusTelemetry, PusTelemetryTimestamp
 from utility.obsw_logger import get_logger
 
 
-
 LOGGER = get_logger()
 
 
-#pylint: disable=too-many-instance-attributes
-#pylint: disable=too-many-arguments
-class PusTelemetryCreator(PusTelemetry):
+# pylint: disable=too-many-instance-attributes
+# pylint: disable=too-many-arguments
+class PusTelemetryCreator:
     """
     Alternative way to create a PUS Telemetry packet by specifying telemetry parameters,
     similarly to the way telecommands are created. This can be used to create telemetry
@@ -25,7 +24,6 @@ class PusTelemetryCreator(PusTelemetry):
         """
         Initiates the unserialized data fields for the PUS telemetry packet.
         """
-        super().__init__()
         # packet type for telemetry is 0 as specified in standard
         packet_type = 0
         # specified in standard
@@ -50,6 +48,18 @@ class PusTelemetryCreator(PusTelemetry):
 
         self.source_data = source_data
 
+    def print(self):
+        """ Print the raw command in a clean format. """
+        packet = self.pack()
+        print_out = "Telemetry in Hexadecimal: ["
+        for counter in range(len(packet)):
+            if counter == len(packet) - 1:
+                print_out += str(hex(packet[counter]))
+            else:
+                print_out += str(hex(packet[counter])) + ", "
+        print_out += "]"
+        LOGGER.info(print_out)
+
     def pack(self) -> bytearray:
         """
         Serializes the PUS telemetry into a raw packet.
@@ -86,7 +96,7 @@ class PusTelemetryCreator(PusTelemetry):
         length of the CRC16 checksum - 1
         """
         try:
-            data_length = 4  + PusTelemetry.PUS_TIMESTAMP_SIZE + len(self.source_data) + 1
+            data_length = 4 + PusTelemetry.PUS_TIMESTAMP_SIZE + len(self.source_data) + 1
             return data_length
         except TypeError:
             LOGGER.error("PusTelecommand: Invalid type of application data!")
-- 
GitLab