From b3e668c06a2c7793bcb6106c626c68016fcddcb0 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Mon, 5 Oct 2020 21:30:19 +0200
Subject: [PATCH] updating run configurations

---
 .../tmtcclient_Clear_SD_Card_.xml             |  24 ++++
 .../tmtcclient_Format_SD_Card_.xml            |  24 ++++
 .../tmtcclient_GPS0_Serial.xml                |   2 +-
 .../tmtcclient_GPS1_Serial.xml                |   2 +-
 .../tmtcclient_Listener_Serial.xml            |   2 +-
 .../tmtcclient_Module_Test_Serial.xml         |   2 +-
 .../tmtcclient_Print_SD_Card.xml              |  24 ++++
 .../tmtcclient_Service_17_Serial.xml          |   2 +-
 .../tmtcclient_Service_2_Serial.xml           |   2 +-
 .../tmtcclient_Service_3_Serial_.xml          |   2 +-
 .../tmtcclient_Service_5_Serial.xml           |   2 +-
 .../tmtcclient_Service_8_Serial.xml           |   2 +-
 .../tmtcclient_Service_9_Serial.xml           |   2 +-
 .../tmtcclient_Single_Command_Serial_.xml     |   2 +-
 .../tmtcclient_Software_Serial.xml            |   2 +-
 .../tmtcclient__Service_200_Serial.xml        |   2 +-
 config/obsw_config.py                         |   9 +-
 obsw_tmtc_client.py                           |   4 +-
 tc/obsw_pus_tc_packer.py                      |   6 +-
 tc/obsw_tc_service23.py                       | 112 +++++++++---------
 utility/obsw_args_parser.py                   |   5 +-
 21 files changed, 160 insertions(+), 74 deletions(-)
 create mode 100644 .idea/runConfigurations/tmtcclient_Clear_SD_Card_.xml
 create mode 100644 .idea/runConfigurations/tmtcclient_Format_SD_Card_.xml
 create mode 100644 .idea/runConfigurations/tmtcclient_Print_SD_Card.xml

diff --git a/.idea/runConfigurations/tmtcclient_Clear_SD_Card_.xml b/.idea/runConfigurations/tmtcclient_Clear_SD_Card_.xml
new file mode 100644
index 0000000..ef06fbd
--- /dev/null
+++ b/.idea/runConfigurations/tmtcclient_Clear_SD_Card_.xml
@@ -0,0 +1,24 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="tmtcclient Clear SD-Card " type="PythonConfigurationType" factoryName="Python" folderName="Serial SD-Card">
+    <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_tmtc_client.py" />
+    <option name="PARAMETERS" value="-m 3 -s 23 -o 181 -c 1 -t 2.5" />
+    <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/.idea/runConfigurations/tmtcclient_Format_SD_Card_.xml b/.idea/runConfigurations/tmtcclient_Format_SD_Card_.xml
new file mode 100644
index 0000000..e0e21bc
--- /dev/null
+++ b/.idea/runConfigurations/tmtcclient_Format_SD_Card_.xml
@@ -0,0 +1,24 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="tmtcclient Format SD-Card " type="PythonConfigurationType" factoryName="Python" folderName="Serial SD-Card">
+    <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_tmtc_client.py" />
+    <option name="PARAMETERS" value="-m 3 -s 23 -o 182 -c 1 -t 2.5" />
+    <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/.idea/runConfigurations/tmtcclient_GPS0_Serial.xml b/.idea/runConfigurations/tmtcclient_GPS0_Serial.xml
index 0f8cd5f..9b348c5 100644
--- a/.idea/runConfigurations/tmtcclient_GPS0_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_GPS0_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient GPS0 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient GPS0 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_GPS1_Serial.xml b/.idea/runConfigurations/tmtcclient_GPS1_Serial.xml
index 1f8098a..41bf9f1 100644
--- a/.idea/runConfigurations/tmtcclient_GPS1_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_GPS1_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient GPS1 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient GPS1 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Listener_Serial.xml b/.idea/runConfigurations/tmtcclient_Listener_Serial.xml
index c59efdb..7c86eae 100644
--- a/.idea/runConfigurations/tmtcclient_Listener_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Listener_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Listener Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Listener Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Module_Test_Serial.xml b/.idea/runConfigurations/tmtcclient_Module_Test_Serial.xml
index 61aa71d..558b183 100644
--- a/.idea/runConfigurations/tmtcclient_Module_Test_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Module_Test_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Module Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Module Test Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Print_SD_Card.xml b/.idea/runConfigurations/tmtcclient_Print_SD_Card.xml
new file mode 100644
index 0000000..4a9950b
--- /dev/null
+++ b/.idea/runConfigurations/tmtcclient_Print_SD_Card.xml
@@ -0,0 +1,24 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="tmtcclient Print SD-Card" type="PythonConfigurationType" factoryName="Python" folderName="Serial SD-Card">
+    <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_tmtc_client.py" />
+    <option name="PARAMETERS" value="-m 3 -s 23 -o 133 -c 1 -t 2.5" />
+    <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/.idea/runConfigurations/tmtcclient_Service_17_Serial.xml b/.idea/runConfigurations/tmtcclient_Service_17_Serial.xml
index 5145e3b..34f10f7 100644
--- a/.idea/runConfigurations/tmtcclient_Service_17_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_17_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 17 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 17 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Service_2_Serial.xml b/.idea/runConfigurations/tmtcclient_Service_2_Serial.xml
index 38316e0..cb47dfa 100644
--- a/.idea/runConfigurations/tmtcclient_Service_2_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_2_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 2 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 2 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Service_3_Serial_.xml b/.idea/runConfigurations/tmtcclient_Service_3_Serial_.xml
index 7b0db83..1eede5c 100644
--- a/.idea/runConfigurations/tmtcclient_Service_3_Serial_.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_3_Serial_.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 3 Serial " type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 3 Serial " type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Service_5_Serial.xml b/.idea/runConfigurations/tmtcclient_Service_5_Serial.xml
index aadf325..b8bd8b4 100644
--- a/.idea/runConfigurations/tmtcclient_Service_5_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_5_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 5 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 5 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Service_8_Serial.xml b/.idea/runConfigurations/tmtcclient_Service_8_Serial.xml
index 1c96bce..06a9a4e 100644
--- a/.idea/runConfigurations/tmtcclient_Service_8_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_8_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 8 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 8 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Service_9_Serial.xml b/.idea/runConfigurations/tmtcclient_Service_9_Serial.xml
index f755f02..1dc493d 100644
--- a/.idea/runConfigurations/tmtcclient_Service_9_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Service_9_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Service 9 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Service 9 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Single_Command_Serial_.xml b/.idea/runConfigurations/tmtcclient_Single_Command_Serial_.xml
index c598140..7be0845 100644
--- a/.idea/runConfigurations/tmtcclient_Single_Command_Serial_.xml
+++ b/.idea/runConfigurations/tmtcclient_Single_Command_Serial_.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Single Command Serial " type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Single Command Serial " type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient_Software_Serial.xml b/.idea/runConfigurations/tmtcclient_Software_Serial.xml
index 0dfd7b1..c95fcb9 100644
--- a/.idea/runConfigurations/tmtcclient_Software_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient_Software_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient Software Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient Software Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/.idea/runConfigurations/tmtcclient__Service_200_Serial.xml b/.idea/runConfigurations/tmtcclient__Service_200_Serial.xml
index ec2175b..ca3689f 100644
--- a/.idea/runConfigurations/tmtcclient__Service_200_Serial.xml
+++ b/.idea/runConfigurations/tmtcclient__Service_200_Serial.xml
@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="tmtcclient  Service 200 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Communication">
+  <configuration default="false" name="tmtcclient  Service 200 Serial" type="PythonConfigurationType" factoryName="Python" folderName="Serial Services">
     <module name="tmtc" />
     <option name="INTERPRETER_OPTIONS" value="" />
     <option name="PARENT_ENVS" value="true" />
diff --git a/config/obsw_config.py b/config/obsw_config.py
index f1421d6..d45e1cc 100644
--- a/config/obsw_config.py
+++ b/config/obsw_config.py
@@ -61,6 +61,7 @@ LOGGER = logging.getLogger(G_TMTC_LOGGER_NAME)
 G_SCRIPT_MODE = 1
 G_MODE_ID = 0
 G_SERVICE = 17
+G_OP_CODE = 0
 G_DISPLAY_MODE = "long"
 
 # General TMTC Settings
@@ -111,9 +112,10 @@ G_TMTC_PRINTER = None
 
 # noinspection PyUnusedLocal
 def set_globals(args):
-    global G_ETHERNET_RECV_ADDRESS, G_ETHERNET_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, G_DISPLAY_MODE,\
-        G_COM_IF, G_COM_PORT, G_SERIAL_TIMEOUT, G_TM_TIMEOUT, G_TC_SEND_TIMEOUT_FACTOR, \
-        G_PRINT_TO_FILE, G_PRINT_HK_DATA, G_PRINT_RAW_TM, G_PRINT_TM
+    global G_ETHERNET_RECV_ADDRESS, G_ETHERNET_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, \
+        G_DISPLAY_MODE, G_COM_IF, G_COM_PORT, G_SERIAL_TIMEOUT, G_TM_TIMEOUT, \
+        G_TC_SEND_TIMEOUT_FACTOR, G_PRINT_TO_FILE, G_PRINT_HK_DATA, G_PRINT_RAW_TM, G_PRINT_TM, \
+        G_OP_CODE, G_RESEND_TC
     if args.mode == 0:
         LOGGER.info("GUI mode not implemented yet !")
     if args.shortDisplayMode:
@@ -159,6 +161,7 @@ def set_globals(args):
     G_COM_PORT = args.com_port
     G_TM_TIMEOUT = args.tm_timeout
     G_RESEND_TC = args.resend_tc
+    G_OP_CODE = args.op_code
     from obsw_user_code import global_setup_hook
     global_setup_hook()
 
diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py
index a84a19e..7a6cb3d 100755
--- a/obsw_tmtc_client.py
+++ b/obsw_tmtc_client.py
@@ -179,7 +179,9 @@ class TmTcHandler:
         elif self.mode == g.ModeList.ServiceTestMode:
             service_queue = deque()
             service_queue_packer = ServiceQueuePacker()
-            service_queue_packer.pack_service_queue(g.G_SERVICE, service_queue)
+            op_code = g.G_OP_CODE
+            service_queue_packer.pack_service_queue(
+                service=g.G_SERVICE, service_queue=service_queue, op_code=op_code)
             if not self.communication_interface.valid:
                 return
             LOGGER.info("Performing service command operation")
diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py
index 23920de..9e009a2 100644
--- a/tc/obsw_pus_tc_packer.py
+++ b/tc/obsw_pus_tc_packer.py
@@ -14,7 +14,7 @@ from tc.obsw_tc_service2 import pack_service2_test_into
 from tc.obsw_tc_service3 import pack_service3_test_into
 from tc.obsw_tc_service8 import pack_service8_test_into
 from tc.obsw_tc_service9 import pack_service9_test_into
-from tc.obsw_tc_service23 import pack_service23_test_into
+from tc.obsw_tc_service23 import pack_service23_commands_into
 from tc.obsw_tc_service20 import pack_service20_test_into
 from tc.obsw_tc_service200 import pack_mode_data, pack_service200_test_into
 from tc.obsw_tc_service5_17 import pack_service5_test_into, pack_service17_test_into
@@ -32,7 +32,7 @@ class ServiceQueuePacker:
     def __init__(self):
         pass
 
-    def pack_service_queue(self, service: Union[int, str], service_queue: TcQueueT):
+    def pack_service_queue(self, service: Union[int, str], op_code: int, service_queue: TcQueueT):
         if service == 2:
             return pack_service2_test_into(service_queue)
         if service == 3:
@@ -48,7 +48,7 @@ class ServiceQueuePacker:
         if service == 20:
             return pack_service20_test_into(service_queue)
         if service == 23:
-            return pack_service23_test_into(service_queue)
+            return pack_service23_commands_into(service_queue, op_code)
         if service == 200:
             return pack_service200_test_into(service_queue)
         if service == "Dummy":
diff --git a/tc/obsw_tc_service23.py b/tc/obsw_tc_service23.py
index c5773c9..04c8689 100644
--- a/tc/obsw_tc_service23.py
+++ b/tc/obsw_tc_service23.py
@@ -8,7 +8,7 @@ import math
 from enum import Enum
 
 import config.obsw_config as g
-from typing import Deque
+from typing import Deque, Union
 
 from tc.obsw_pus_tc_packer import PusTelecommand, TcQueueT
 from tmtc_core.utility.obsw_logger import get_logger
@@ -66,11 +66,11 @@ class FileTransferHelper:
         # This will generater a telecommand to rename the old file, if it exists
         self.rename_old_file = False
 
-    def set_data(self, local_filename: str):
+    def set_data_from_file(self, local_filename: str):
         with open(local_filename, 'rb') as file:
             self.file_data = file.read()
 
-    def set_data(self, tc_data: bytearray):
+    def set_data_raw(self, tc_data: bytearray):
         self.file_data = tc_data
 
     def set_to_delete_old_file(self):
@@ -205,7 +205,7 @@ def generate_format_sd_card_packet(
 def generate_create_file_srv23_1_packet(
         filename: str, repository_path: str, ssc: int, max_size_of_app_data: int,
         initial_data: bytearray = bytearray([]),
-        object_id: bytearray = g.SD_CARD_HANDLER_ID) -> PusTelecommand:
+        object_id: bytearray = g.SD_CARD_HANDLER_ID) -> Union[PusTelecommand, None]:
     if len(initial_data) > calculate_allowed_file_data_size(
             max_size_of_app_data, filename, repository_path):
         LOGGER.error("generate_create_file_srv23_1_packet: Initial data too large!")
@@ -322,56 +322,62 @@ def generate_read_file_srv23_129_packet(
     return PusTelecommand(service=23, subservice=129, ssc=ssc, app_data=data_to_pack)
 
 
-def pack_service23_test_into(tc_queue: Deque) -> Deque:
+def pack_service23_commands_into(tc_queue: Deque, op_code: int) -> Deque:
     # sd_handler_id = g.SD_CARD_HANDLER_ID
-    tc_queue.appendleft(("print", "Testing Service 23"))
-
-    tc_queue.append(("print", "Formatting file system"))
-    command = generate_format_sd_card_packet(ssc=2390)
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    tc_queue.append(("print", "Create directory 'test'"))
-    command = generate_mkdir_srv23_9_packet(directory_name="test", repository_path="/", ssc=2300)
-    tc_queue.appendleft(command.pack_command_tuple())
-    tc_queue.append(("print", "Create subdirectory 'subdir' in 'test'"))
-    command = generate_mkdir_srv23_9_packet(repository_path="test", ssc=2301,
-                                            directory_name="subdir")
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    tc_queue.appendleft(("print", "Create test.bin"))
-    command = generate_create_file_srv23_1_packet(
-         filename="test.bin", repository_path="test/subdir", ssc=2302,
-         initial_data=bytearray([0x01, 0x00, 0x01, 0x00]),
-         max_size_of_app_data=1024)
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    tc_queue.appendleft(("print", "Printing file structure."))
-    command = generate_print_sd_card_packet(ssc=2300)
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    tc_queue.appendleft(("print", "Clearing SD card"))
-    command = generate_clear_sd_card_packet(ssc=2301)
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    tc_queue.appendleft(("print", "Printing file structure"))
-    command = generate_print_sd_card_packet(ssc=2302)
-    tc_queue.appendleft(command.pack_command_tuple())
-
-    # tc_queue.appendleft(("print", "Read data of test.bin"))
-    # command = generate_read_file_srv23_129_packet("test/subdir", "test.bin", ssc=2303)
-    # tc_queue.appendleft(command.pack_command_tuple())
-    # tc_queue.appendleft(("print", "Delete 'test.bin'"))
-    # command = generate_rm_file_srv23_2_packet(filename="test.bin", repository_path="test/subdir",
-    #                                           ssc=2304)
-    # tc_queue.appendleft(command.pack_command_tuple())
-    # tc_queue.appendleft(("print", "Delete 'subdir' directory"))
-    # command = generate_rmdir_srv23_10_packet(directory_name="subdir", repository_path="test",
-    #                                          ssc=2305)
-    # tc_queue.appendleft(command.pack_command_tuple())
-    # tc_queue.appendleft(("print", "Delete 'test' directory"))
-    # command = generate_rmdir_srv23_10_packet(directory_name="test", repository_path="/",
-    #                                          ssc=2306)
-    # tc_queue.appendleft(command.pack_command_tuple())
+    if op_code == 0:
+        tc_queue.appendleft(("print", "Testing Service 23"))
+
+        tc_queue.append(("print", "Create directory 'test'"))
+        command = generate_mkdir_srv23_9_packet(directory_name="test", repository_path="/", ssc=2300)
+        tc_queue.appendleft(command.pack_command_tuple())
+        tc_queue.append(("print", "Create subdirectory 'subdir' in 'test'"))
+        command = generate_mkdir_srv23_9_packet(repository_path="test", ssc=2301,
+                                                directory_name="subdir")
+        tc_queue.appendleft(command.pack_command_tuple())
+
+        tc_queue.appendleft(("print", "Create test.bin"))
+        command = generate_create_file_srv23_1_packet(
+             filename="test.bin", repository_path="test/subdir", ssc=2302,
+             initial_data=bytearray([0x01, 0x00, 0x01, 0x00]),
+             max_size_of_app_data=1024)
+        tc_queue.appendleft(command.pack_command_tuple())
+
+        tc_queue.appendleft(("print", "Printing file structure."))
+        command = generate_print_sd_card_packet(ssc=2300)
+        tc_queue.appendleft(command.pack_command_tuple())
+
+        tc_queue.appendleft(("print", "Clearing SD card"))
+        command = generate_clear_sd_card_packet(ssc=2301)
+        tc_queue.appendleft(command.pack_command_tuple())
+
+        tc_queue.appendleft(("print", "Printing file structure"))
+        command = generate_print_sd_card_packet(ssc=2302)
+        tc_queue.appendleft(command.pack_command_tuple())
+
+        # tc_queue.appendleft(("print", "Read data of test.bin"))
+        # command = generate_read_file_srv23_129_packet("test/subdir", "test.bin", ssc=2303)
+        # tc_queue.appendleft(command.pack_command_tuple())
+        tc_queue.appendleft(("print", "Delete 'test.bin'"))
+        command = generate_rm_file_srv23_2_packet(
+            filename="test.bin", repository_path="test/subdir", ssc=2304)
+        tc_queue.appendleft(command.pack_command_tuple())
+        tc_queue.appendleft(("print", "Delete 'subdir' directory"))
+        command = generate_rmdir_srv23_10_packet(directory_name="subdir", repository_path="test",
+                                                 ssc=2305)
+        tc_queue.appendleft(command.pack_command_tuple())
+        tc_queue.appendleft(("print", "Delete 'test' directory"))
+        command = generate_rmdir_srv23_10_packet(directory_name="test", repository_path="/",
+                                                 ssc=2306)
+        tc_queue.appendleft(command.pack_command_tuple())
+    elif op_code == 133:
+        tc_queue.append(("print", "Printing active file system"))
+        command = generate_print_sd_card_packet(ssc=2300)
+        tc_queue.appendleft(command.pack_command_tuple())
+    elif op_code == 182:
+        tc_queue.append(("print", "Formatting active file system"))
+        command = generate_format_sd_card_packet(ssc=2300)
+        tc_queue.appendleft(command.pack_command_tuple())
+
     # tc_queue.appendleft(("print", "\r"))
     return tc_queue
 
diff --git a/utility/obsw_args_parser.py b/utility/obsw_args_parser.py
index eaacb7d..3769416 100644
--- a/utility/obsw_args_parser.py
+++ b/utility/obsw_args_parser.py
@@ -24,6 +24,9 @@ def parse_input_arguments():
     arg_parser.add_argument(
         '-c', '--com_if', type=int, help='Communication Interface. 0: Dummy Interface, 1: Serial, '
         '2: QEMU, 3: UDP', default=2)
+    arg_parser.add_argument(
+        '-o', '--op_code', type=int, help='Operation code, which is passed to the TC '
+        'packer functions', default=0)
     arg_parser.add_argument('--clientIP', help='Client(Computer) IP. Default:\'\'', default='')
     arg_parser.add_argument(
         '--boardIP', help='Board IP. Default: Localhost 127.0.0.1', default="127.0.0.1")
@@ -38,7 +41,7 @@ def parse_input_arguments():
         '--np', dest='print_tm', help='Supply --np to suppress print output to console.',
         action='store_false')
     arg_parser.add_argument(
-        '-o', '--tc_timeout_factor', type=float, help='TC Timeout Factor. Multiplied with '
+        '--tc_timeout_factor', type=float, help='TC Timeout Factor. Multiplied with '
         'TM Timeout, TC sent again after this time period. Default: 3.5', default=3.5)
     arg_parser.add_argument(
         '-r', '--rawDataPrint', help='Supply -r to print all raw TM data directly',
-- 
GitLab