From 9b176aebfaba51f4d045881a125d42b123f4eeb3 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 31 Aug 2021 11:17:01 +0200 Subject: [PATCH] commands for ploc memory dumper --- config/definitions.py | 1 + config/hook_implementations.py | 7 +++++- config/object_ids.py | 1 + pus_tc/ploc_memory_dumper.py | 41 ++++++++++++++++++++++++++++++++++ pus_tc/ploc_supervisor.py | 15 ------------- pus_tc/ploc_upater.py | 2 -- pus_tc/tc_packer_hook.py | 6 ++++- 7 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 pus_tc/ploc_memory_dumper.py diff --git a/config/definitions.py b/config/definitions.py index 16884fc..50f4577 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -30,5 +30,6 @@ class CustomServiceList(enum.Enum): RAD_SENSOR = "rad_sensor" PLOC_SUPV = "ploc_supv" PLOC_UPDATER = "ploc_updater" + PLOC_MEMORY_DUMPER = "ploc_memory_dumper" CORE = 'core' STAR_TRACKER = 'star_tracker' diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 5983199..fa1fd53 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -106,6 +106,11 @@ class EiveHookObject(TmTcHookBase): } service_rad_sensor_tuple = ("Radiation Sensor", op_code_dict_srv_rad_sensor) + op_code_dict_ploc_mem_dumper = { + "0": ("PLOC Memory Dumper: MRAM dump", {OpCodeDictKeys.TIMEOUT: 2.0}), + } + service_ploc_memory_dumper_tuple = ("Radiation Sensor", op_code_dict_ploc_mem_dumper) + op_code_dict_srv_ploc_supv = { "0": ("PLOC Supervisor: Set mode on", {OpCodeDictKeys.TIMEOUT: 2.0}), "1": ("PLOC Supervisor: Set mode normal", {OpCodeDictKeys.TIMEOUT: 2.0}), @@ -139,7 +144,6 @@ class EiveHookObject(TmTcHookBase): "29": ("PLOC Supervisor: Select NVM", {OpCodeDictKeys.TIMEOUT: 2.0}), "30": ("PLOC Supervisor: Run auto EM tests", {OpCodeDictKeys.TIMEOUT: 2.0}), "31": ("PLOC Supervisor: MRAM Wipe", {OpCodeDictKeys.TIMEOUT: 2.0}), - "32": ("PLOC Supervisor: MRAM Dump", {OpCodeDictKeys.TIMEOUT: 2.0}), "33": ("PLOC Supervisor: Print CPU stats", {OpCodeDictKeys.TIMEOUT: 2.0}), "34": ("PLOC Supervisor: Set debug verbosity", {OpCodeDictKeys.TIMEOUT: 2.0}), "35": ("PLOC Supervisor: Set GPIO", {OpCodeDictKeys.TIMEOUT: 2.0}), @@ -182,6 +186,7 @@ class EiveHookObject(TmTcHookBase): service_op_code_dict[CustomServiceList.PLOC_SUPV.value] = service_ploc_supv_tuple service_op_code_dict[CustomServiceList.PLOC_UPDATER.value] = service_ploc_updater_tuple service_op_code_dict[CustomServiceList.STAR_TRACKER.value] = service_star_tracker_tuple + service_op_code_dict[CustomServiceList.PLOC_MEMORY_DUMPER.value] = service_ploc_memory_dumper_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 932dc50..43335e4 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -28,6 +28,7 @@ RAD_SENSOR_ID = bytes([0x44, 0x32, 0x00, 0xA5]) PLOC_SUPV_ID = bytes([0x44, 0x33, 0x00, 0x16]) PLOC_UPDATER_ID = bytes([0x44, 0x33, 0x00, 0x00]) CORE_CONTROLLER_ID = bytes([0x43, 0x00, 0x00, 0x03]) +PLOC_MEMORY_DUMPER_ID = bytes([0x44, 0x33, 0x00, 0x01]) def get_object_ids() -> Dict[bytes, list]: diff --git a/pus_tc/ploc_memory_dumper.py b/pus_tc/ploc_memory_dumper.py new file mode 100644 index 0000000..60a4271 --- /dev/null +++ b/pus_tc/ploc_memory_dumper.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +""" +@file ploc_memory_dumper.py +@brief This file implements the command to dump memory sectors of the PLOC. Memories of the PLOC which can be dumped + are one MRAM, two flash memories and the SRAM. +@author J. Meier +@date 31.08.2021 +""" +import struct + +from tmtccmd.config.definitions import QueueCommands + +from tmtccmd.tc.packer import TcQueueT +from tmtccmd.ecss.tc import PusTelecommand + + +class ActionIds: + DUMP_MRAM = 1 + + +def pack_ploc_memory_dumper_cmd(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: + tc_queue.appendleft( + (QueueCommands.PRINT, + "Testing PLOC memory dumper with object id: 0x" + object_id.hex()) + ) + + if op_code == "0": + tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Dump MRAM")) + command = pack_mram_dump_cmd(object_id) + command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + + +def pack_mram_dump_cmd(object_id: bytearray) -> bytearray: + start = int(input("Start address: 0x"), 16) + end = int(input("End address: 0x"), 16) + command = bytearray() + command = object_id + struct.pack('!I', ActionIds.DUMP_MRAM) + command = command + struct.pack('!I', start) + command = command + struct.pack('!I', end) + return command diff --git a/pus_tc/ploc_supervisor.py b/pus_tc/ploc_supervisor.py index 6bbd1ad..31f9627 100644 --- a/pus_tc/ploc_supervisor.py +++ b/pus_tc/ploc_supervisor.py @@ -232,11 +232,6 @@ def pack_ploc_supv_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: command = pack_mram_wipe_cmd(object_id) command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - elif op_code == "32": - tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Dump MRAM")) - command = pack_mram_dump_cmd(object_id) - command = PusTelecommand(service=8, subservice=128, ssc=47, app_data=command) - tc_queue.appendleft(command.pack_command_tuple()) elif op_code == "33": tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Print CPU stats")) command = pack_print_cpu_stats_cmd(object_id) @@ -508,16 +503,6 @@ def pack_mram_wipe_cmd(object_id: bytearray) -> bytearray: return command -def pack_mram_dump_cmd(object_id: bytearray) -> bytearray: - start = int(input("Start address: 0x"), 16) - stop = int(input("Stop address: 0x"), 16) - command = bytearray() - command = object_id + struct.pack('!I', SupvActionIds.DUMP_MRAM) - command = command + struct.pack('!I', start) - command = command + struct.pack('!I', stop) - return command - - def pack_print_cpu_stats_cmd(object_id: bytearray) -> bytearray: en = 1 command = bytearray() diff --git a/pus_tc/ploc_upater.py b/pus_tc/ploc_upater.py index 471d8c9..6721013 100644 --- a/pus_tc/ploc_upater.py +++ b/pus_tc/ploc_upater.py @@ -13,9 +13,7 @@ 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", diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index f7022ff..d88c966 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -27,12 +27,13 @@ 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 pus_tc.ploc_memory_dumper import pack_ploc_memory_dumper_cmd from pus_tc.core import pack_core_commands from pus_tc.star_tracker import pack_star_tracker_commands_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, PLOC_UPDATER_ID, STAR_TRACKER_ID + RAD_SENSOR_ID, PLOC_SUPV_ID, PLOC_UPDATER_ID, STAR_TRACKER_ID, PLOC_MEMORY_DUMPER_ID LOGGER = get_console_logger() @@ -98,6 +99,9 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu return pack_star_tracker_commands_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.CORE.value: return pack_core_commands(tc_queue=service_queue, op_code=op_code) + if service == CustomServiceList.PLOC_MEMORY_DUMPER.value: + object_id = PLOC_MEMORY_DUMPER_ID + return pack_ploc_memory_dumper_cmd(object_id=object_id, tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !")