From 36ae6a233c582a7bb7c59edaf35a64a284c7fde9 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Sat, 7 Aug 2021 14:34:26 +0200 Subject: [PATCH] ploc udpater test --- config/definitions.py | 1 + config/hook_implementations.py | 9 ++++++ config/object_ids.py | 1 + pus_tc/ploc_upater.py | 52 ++++++++++++++++++++++++++++++++++ pus_tc/tc_packer_hook.py | 6 +++- 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 pus_tc/ploc_upater.py diff --git a/config/definitions.py b/config/definitions.py index 771eb06..e9e11fa 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -29,3 +29,4 @@ class CustomServiceList(enum.Enum): REACTION_WHEEL_4 = "reaction_wheel_4" RAD_SENSOR = "rad_sensor" PLOC_SUPV = "ploc_supv" + PLOC_UPDATER = "ploc_updater" diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 57005f4..584de70 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -126,6 +126,14 @@ class EiveHookObject(TmTcHookBase): } service_ploc_supv_tuple = ("PLOC Supervisor", op_code_dict_srv_ploc_supv) + op_code_dict_srv_ploc_updater = { + "0": ("Ploc Updater: Update partion A on NVM0", {OpCodeDictKeys.TIMEOUT: 2.0}), + "1": ("Ploc Updater: Update partion B on NVM0", {OpCodeDictKeys.TIMEOUT: 2.0}), + "2": ("Ploc Updater: Update partion A on NVM1", {OpCodeDictKeys.TIMEOUT: 2.0}), + "3": ("Ploc Updater: Update partion B on NVM1", {OpCodeDictKeys.TIMEOUT: 2.0}), + } + service_ploc_updater_tuple = ("Ploc Updater", op_code_dict_srv_ploc_updater) + service_op_code_dict[CustomServiceList.ACU.value] = service_acu_tuple service_op_code_dict[CustomServiceList.TMP1075_1.value] = service_tmp1075_1_tuple service_op_code_dict[CustomServiceList.TMP1075_2.value] = service_tmp1075_2_tuple @@ -140,6 +148,7 @@ class EiveHookObject(TmTcHookBase): service_op_code_dict[CustomServiceList.REACTION_WHEEL_4.value] = service_rw_tuple service_op_code_dict[CustomServiceList.RAD_SENSOR.value] = service_rad_sensor_tuple service_op_code_dict[CustomServiceList.PLOC_SUPV.value] = service_ploc_supv_tuple + service_op_code_dict[CustomServiceList.PLOC_UPDATER.value] = service_ploc_updater_tuple return service_op_code_dict def get_json_config_file_path(self) -> str: diff --git a/config/object_ids.py b/config/object_ids.py index 5d6b3e7..b105b89 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -26,6 +26,7 @@ RW4_ID = bytes([0x44, 0x12, 0x00, 0x4]) START_TRACKER_ID = bytes([0x44, 0x13, 0x00, 0x1]) RAD_SENSOR_ID = bytes([0x44, 0x32, 0x00, 0xA5]) PLOC_SUPV_ID = bytes([0x44, 0x33, 0x00, 0x16]) +PLOC_UPDATER_ID = bytes([0x44, 0x33, 0x00, 0x00]) def get_object_ids() -> Dict[bytes, list]: diff --git a/pus_tc/ploc_upater.py b/pus_tc/ploc_upater.py new file mode 100644 index 0000000..c2beede --- /dev/null +++ b/pus_tc/ploc_upater.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +""" +@file ploc_supervisor.py +@brief Tests for commanding the supervisor of the PLOC. + The supervisor is programmed by Thales. +@author J. Meier +@date 10.07.2021 +""" +import struct + +from tmtccmd.config.definitions import QueueCommands + +from tmtccmd.tc.packer import TcQueueT +from tmtccmd.ecss.tc import PusTelecommand +from tmtccmd.utility.logger import get_console_logger + +LOGGER = get_console_logger() + +latchup_id_dict = { + "0": "0.85V", + "1": "1.8V", + "2": "MISC", + "3": "3.3V", + "4": "NVM_4XO", + "5": "MISSION", + "6": "SAFECOTS" +} + + +class UpdaterActionIds: + UPDATE_NVM0_A = 0 + UPDATE_NVM0_B = 1 + UPDATE_NVM1_A = 2 + UPDATE_NVM1_B = 3 + + +class ImagePathDefs: + imageNvm0A = "/mnt/sd0/ploc/updateNvm0A.bin" + + +def pack_ploc_updater_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: + tc_queue.appendleft( + (QueueCommands.PRINT, + "Testing PLOC updater with object id: 0x" + object_id.hex()) + ) + + if op_code == "0": + tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update partition A on NVM0")) + command = object_id + struct.pack('!I', UpdaterActionIds.UPDATE_NVM0_A) + \ + bytearray(ImagePathDefs.imageNvm0A, 'utf-8') + command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 80d893f..dddf999 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -26,10 +26,11 @@ from pus_tc.ploc_supervisor import pack_ploc_supv_test_into from pus_tc.heater import pack_heater_test_into from pus_tc.reaction_wheels import pack_single_rw_test_into from pus_tc.rad_sensor import pack_rad_sensor_test_into +from pus_tc.ploc_upater import pack_ploc_updater_test_into from config.definitions import CustomServiceList from config.object_ids import P60_DOCK_HANDLER, PDU_1_HANDLER_ID, PDU_2_HANDLER_ID, ACU_HANDLER_ID, \ TMP_1075_1_HANDLER_ID, TMP_1075_2_HANDLER_ID, HEATER_ID, IMTQ_HANDLER_ID, PLOC_MPSOC_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID, \ - RAD_SENSOR_ID, PLOC_SUPV_ID + RAD_SENSOR_ID, PLOC_SUPV_ID, PLOC_UPDATER_ID LOGGER = get_console_logger() @@ -93,6 +94,9 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu if service == CustomServiceList.PLOC_SUPV.value: object_id = PLOC_SUPV_ID return pack_ploc_supv_test_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) + if service == CustomServiceList.PLOC_UPDATER.value: + object_id = PLOC_UPDATER_ID + return pack_ploc_updater_test_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !")