From 75ae2c786b2422ea1986ce69bdcd528346e88f1a Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 26 Jul 2021 16:29:54 +0200 Subject: [PATCH] update availabe and watchdogs enable command --- config/hook_implementations.py | 2 ++ pus_tc/ploc_supervisor.py | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index c5869d9..aaeddd0 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -96,6 +96,8 @@ class EiveHookObject(TmTcHookBase): "11": ("PLOC Supervisor: Set boot timeout", {OpCodeDictKeys.TIMEOUT: 2.0}), "12": ("PLOC Supervisor: Disable Hk", {OpCodeDictKeys.TIMEOUT: 2.0}), "13": ("PLOC Supervisor: Request boot status report", {OpCodeDictKeys.TIMEOUT: 2.0}), + "14": ("PLOC Supervisor: Update available", {OpCodeDictKeys.TIMEOUT: 2.0}), + "15": ("PLOC Supervisor: Watchdogs enable", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_ploc_supv_tuple = ("PLOC Supervisor", op_code_dict_srv_ploc_supv) diff --git a/pus_tc/ploc_supervisor.py b/pus_tc/ploc_supervisor.py index f2ce4e0..34fbbef 100644 --- a/pus_tc/ploc_supervisor.py +++ b/pus_tc/ploc_supervisor.py @@ -26,6 +26,8 @@ class SupvActionIds: SET_TIME_REF = 9 DISABLE_HK = 10 GET_BOOT_STATUS_REPORT = 11 + UPDATE_AVAILABLE = 12 + WATCHDOGS_ENABLE = 13 class SupvHkIds: @@ -100,6 +102,16 @@ def pack_ploc_supv_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: command = object_id + struct.pack('!I', SupvActionIds.GET_BOOT_STATUS_REPORT) command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + elif op_code == "14": + tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update available")) + command = pack_update_available_cmd(object_id) + command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + elif op_code == "15": + tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Watchdogs Enable")) + command = pack_watchdogs_enable_cmd(object_id) + command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) return tc_queue @@ -119,3 +131,40 @@ def pack_sel_boot_image_cmd(object_id: bytearray, mem: int, bp0: int, bp1: int, command = command + struct.pack('!B', bp1) command = command + struct.pack('!B', bp2) return command + + +def pack_update_available_cmd(object_id: bytearray) -> bytearray: + """ + @brief This function packs the udpate availabe command. + @param object_id The object id of the PLOC supervisor handler. + """ + image_select = 1 + image_partition = 0 + image_size = 222 + image_crc = 0x0 + number_of_packets = 150 + command = bytearray() + command = object_id + struct.pack('!I', SupvActionIds.UPDATE_AVAILABLE) + command = command + struct.pack('!B', image_select) + command = command + struct.pack('!B', image_partition) + command = command + struct.pack('!I', image_size) + command = command + struct.pack('!I', image_crc) + command = command + struct.pack('!I', number_of_packets) + return command + + +def pack_watchdogs_enable_cmd(object_id: bytearray) -> bytearray: + """ + @brief This function packs the command to enable or disable watchdogs on the PLOC. + @param object_id The object id of the PLOC supervisor handler. + @note Enable = 1, Disable = 0 + """ + watchdog_ps = 1 + watchdog_pl = 1 + watchdog_int = 0 + command = bytearray() + command = object_id + struct.pack('!I', SupvActionIds.WATCHDOGS_ENABLE) + command = command + struct.pack('!B', watchdog_ps) + command = command + struct.pack('!B', watchdog_pl) + command = command + struct.pack('!B', watchdog_int) + return command