From 32f5d3863d324ef0d28e1c13af6f430962f3d58b Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Thu, 8 Oct 2020 00:53:52 +0200
Subject: [PATCH] commands added

---
 .../tmtcclient_PowerCycle_OBC_.xml            |  2 +-
 .../tmtcclient_Reset_OBC.xml                  |  2 +-
 tc/obsw_tc_core.py                            | 24 +++++++++++++++++--
 utility/obsw_binary_uploader.py               |  3 ++-
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/.idea/runConfigurations/tmtcclient_PowerCycle_OBC_.xml b/.idea/runConfigurations/tmtcclient_PowerCycle_OBC_.xml
index d91d260..b443130 100644
--- a/.idea/runConfigurations/tmtcclient_PowerCycle_OBC_.xml
+++ b/.idea/runConfigurations/tmtcclient_PowerCycle_OBC_.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 Core -o 11 -c 1 -t 2.5" />
+    <option name="PARAMETERS" value="-m 3 -s Core -o A11 -c 1 -t 2.5" />
     <option name="SHOW_COMMAND_LINE" value="false" />
     <option name="EMULATE_TERMINAL" value="true" />
     <option name="MODULE_MODE" value="false" />
diff --git a/.idea/runConfigurations/tmtcclient_Reset_OBC.xml b/.idea/runConfigurations/tmtcclient_Reset_OBC.xml
index ec4edab..3e52938 100644
--- a/.idea/runConfigurations/tmtcclient_Reset_OBC.xml
+++ b/.idea/runConfigurations/tmtcclient_Reset_OBC.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 Core -o 10 -c 1 -t 2.5" />
+    <option name="PARAMETERS" value="-m 3 -s Core -o A10 -c 1 -t 2.5" />
     <option name="SHOW_COMMAND_LINE" value="false" />
     <option name="EMULATE_TERMINAL" value="true" />
     <option name="MODULE_MODE" value="false" />
diff --git a/tc/obsw_tc_core.py b/tc/obsw_tc_core.py
index 700a5a2..be4a2fa 100644
--- a/tc/obsw_tc_core.py
+++ b/tc/obsw_tc_core.py
@@ -5,14 +5,34 @@ from tc.obsw_tc_service8 import make_action_id
 from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand
 
 
-def pack_core_command(tc_queue: Deque, op_code: int, ssc: int = 0):
-    if op_code == 10:
+def pack_core_command(tc_queue: Deque, op_code, ssc: int = 0):
+    if op_code.lower() == "a0":
+        tc_queue.appendleft(("print", "Generating OBC run time stats"))
+        command = generate_run_time_stats_generation_command(ssc=ssc)
+        tc_queue.appendleft(command.pack_command_tuple())
+    if op_code.lower() == "a10":
         tc_queue.appendleft(("print", "Resetting OBC."))
         command = generate_reset_obc_command(ssc=ssc)
         tc_queue.appendleft(command.pack_command_tuple())
+    if op_code.lower() == "a11":
+        tc_queue.appendleft(("print", "Power cycling OBC."))
+        command = generate_power_cycle_obc_command(ssc=ssc)
+        tc_queue.appendleft(command.pack_command_tuple())
 
 
 def generate_reset_obc_command(ssc: int, object_id: bytearray = CORE_CONTROLLER_ID):
     app_data = bytearray(object_id)
     app_data += make_action_id(10)
     return PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=app_data)
+
+
+def generate_power_cycle_obc_command(ssc: int, object_id: bytearray = CORE_CONTROLLER_ID):
+    app_data = bytearray(object_id)
+    app_data += make_action_id(11)
+    return PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=app_data)
+
+
+def generate_run_time_stats_generation_command(ssc: int, object_id: bytearray = CORE_CONTROLLER_ID):
+    app_data = bytearray(object_id)
+    app_data += make_action_id(0)
+    return PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=app_data)
diff --git a/utility/obsw_binary_uploader.py b/utility/obsw_binary_uploader.py
index 412bcdc..996f295 100644
--- a/utility/obsw_binary_uploader.py
+++ b/utility/obsw_binary_uploader.py
@@ -156,7 +156,8 @@ def perform_file_upload(com_if: CommunicationInterface, tmtc_printer: TmTcPrinte
             tmtc_printer.print_telecommand(tc_packet, tc_info)
         elif tc_packet == "print":
             LOGGER.info(tc_info)
-        remaining_time_string = "Remaining time: " + str(total_time - (idx - 2) * interval) + \
+        remaining_time_string = "Remaining time: " + \
+                                str(round(total_time - (idx - 2) * interval, 2)) + \
                                 " seconds"
         print_progress_bar(idx - 2, total_num_packets, print_end="\n", suffix=remaining_time_string)
         # sys.stdout.write("\033[F")  # Cursor up one line
-- 
GitLab