From 69dc4dcc214657cd43ca488a2d65b183a08c2921 Mon Sep 17 00:00:00 2001
From: Robin Mueller <robin.mueller.m@gmail.com>
Date: Fri, 31 Jan 2020 17:28:27 +0100
Subject: [PATCH] TC printer added

---
 .idea/runConfigurations/MIB_Objects.xml       | 24 -------------------
 ...BSW_TmTc_Client_Service_17_Test_Serial.xml | 24 -------------------
 OBSW_TmTcClient.py                            | 11 +++++----
 .../OBSW_SingleCommandSenderReceiver.py       |  6 ++++-
 tc/OBSW_TcPacket.py                           | 10 ++++++++
 5 files changed, 21 insertions(+), 54 deletions(-)
 delete mode 100644 .idea/runConfigurations/MIB_Objects.xml
 delete mode 100644 .idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml

diff --git a/.idea/runConfigurations/MIB_Objects.xml b/.idea/runConfigurations/MIB_Objects.xml
deleted file mode 100644
index bb0256d..0000000
--- a/.idea/runConfigurations/MIB_Objects.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="MIB_Objects" type="PythonConfigurationType" factoryName="Python" folderName="MIB">
-    <module name="generators" />
-    <option name="INTERPRETER_OPTIONS" value="" />
-    <option name="PARENT_ENVS" value="true" />
-    <envs>
-      <env name="PYTHONUNBUFFERED" value="1" />
-    </envs>
-    <option name="SDK_HOME" value="" />
-    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../generators/objects" />
-    <option name="IS_MODULE_SDK" value="true" />
-    <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="$PROJECT_DIR$/../generators/objects/MIB_Objects.py" />
-    <option name="PARAMETERS" value="" />
-    <option name="SHOW_COMMAND_LINE" value="false" />
-    <option name="EMULATE_TERMINAL" value="false" />
-    <option name="MODULE_MODE" value="false" />
-    <option name="REDIRECT_INPUT" value="false" />
-    <option name="INPUT_FILE" value="" />
-    <method v="2" />
-  </configuration>
-</component>
\ No newline at end of file
diff --git a/.idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml b/.idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml
deleted file mode 100644
index 0dd68ef..0000000
--- a/.idea/runConfigurations/OBSW_TmTc_Client_Service_17_Test_Serial.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <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" />
-    <envs>
-      <env name="PYTHONUNBUFFERED" value="1" />
-    </envs>
-    <option name="SDK_HOME" value="" />
-    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
-    <option name="IS_MODULE_SDK" value="true" />
-    <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="$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" />
-    <option name="MODULE_MODE" value="false" />
-    <option name="REDIRECT_INPUT" value="false" />
-    <option name="INPUT_FILE" value="" />
-    <method v="2" />
-  </configuration>
-</component>
\ No newline at end of file
diff --git a/OBSW_TmTcClient.py b/OBSW_TmTcClient.py
index ca7def3..73c2944 100644
--- a/OBSW_TmTcClient.py
+++ b/OBSW_TmTcClient.py
@@ -119,11 +119,12 @@ def main():
 def commandPreparation():
     # Direct command which triggers an additional step reply and one completion reply
     # Single Command Testing
-    #command = PUSTelecommand(service=17, subservice=1, SSC=21)
-    file = bytearray([1, 2, 3, 4, 5])
-    command = PUSTelecommand(service=23, subservice=1, SSC=21, data=file)
-    command.packCommandTuple()
-    return command.packCommandTuple()
+    command = PUSTelecommand(service=17, subservice=1, SSC=21)
+    command.print()
+    # file = bytearray([1, 2, 3, 4, 5])
+    # command = PUSTelecommand(service=23, subservice=1, SSC=21, data=file)
+    # command.packCommandTuple()
+    # return command.packCommandTuple()
 
 
 def setUpSocket():
diff --git a/sendreceive/OBSW_SingleCommandSenderReceiver.py b/sendreceive/OBSW_SingleCommandSenderReceiver.py
index 4b025b7..d686b05 100644
--- a/sendreceive/OBSW_SingleCommandSenderReceiver.py
+++ b/sendreceive/OBSW_SingleCommandSenderReceiver.py
@@ -18,7 +18,11 @@ class SingleCommandSenderReceiver(CommandSenderReceiver):
     def __init__(self, comInterface, displayMode, pusPacketTuple, tmTimeout, tcTimeoutFactor, doPrintToFile):
         super().__init__(comInterface, displayMode, tmTimeout, tcTimeoutFactor, doPrintToFile)
         self.pusPacketTuple = pusPacketTuple
-        (self.pusPacketInfo, self.pusPacket) = self.pusPacketTuple
+        try:
+            (self.pusPacketInfo, self.pusPacket) = self.pusPacketTuple
+        except TypeError:
+            print("Invalid queue entry detected")
+            exit()
 
     def sendSingleTcAndReceiveTm(self):
         print("Starting listener thread")
diff --git a/tc/OBSW_TcPacket.py b/tc/OBSW_TcPacket.py
index 9548dad..8151e0d 100644
--- a/tc/OBSW_TcPacket.py
+++ b/tc/OBSW_TcPacket.py
@@ -65,6 +65,16 @@ class PUSTelecommand:
         commandTuple = (self.packInformation(), self.pack())
         return commandTuple
 
+    def print(self):
+        packet = self.pack()
+        print("Command in Hexadecimal: [", end="")
+        for counter in range(len(packet)):
+            if counter == len(packet) - 1:
+                print(str(hex(packet[counter])), end="")
+            else:
+                print(str(hex(packet[counter])) + ", ", end="")
+        print("]")
+
 
 # Takes pusPackets, removes current Packet Error Control, calculates new CRC (16 bits at packet end) and
 # adds it as correct Packet Error Control Code. Reference: ECSS-E70-41A p. 207-212
-- 
GitLab