eive-tmtc/eive_tmtc/tmtc/payload/ploc_memory_dumper.py

50 lines
1.6 KiB
Python
Raw Normal View History

2021-08-31 11:17:01 +02:00
# -*- coding: utf-8 -*-
"""
@file ploc_memory_dumper.py
2023-06-19 17:16:00 +02:00
@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.
2021-08-31 11:17:01 +02:00
@author J. Meier
@date 31.08.2021
"""
import struct
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.definitions import CustomServiceList
2021-10-01 10:55:56 +02:00
from spacepackets.ecss.tc import PusTelecommand
2022-08-18 15:52:06 +02:00
from tmtccmd.config import TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdU32
2021-08-31 11:17:01 +02:00
2023-01-16 14:13:06 +01:00
class ActionId:
2021-08-31 11:17:01 +02:00
DUMP_MRAM = 1
2022-08-18 15:52:06 +02:00
@tmtc_definitions_provider
def add_ploc_mem_dumper_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add("0", "PLOC Memory Dumper: MRAM dump")
defs.add_service(CustomServiceList.PLOC_MEMORY_DUMPER, "PLOC Memory Dumper", oce)
2022-08-08 16:32:18 +02:00
def pack_ploc_memory_dumper_cmd(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
2022-07-04 17:59:09 +02:00
q.add_log_cmd(
f"Testing PLOC memory dumper with object id: {object_id.as_hex_string}"
2021-08-31 11:17:01 +02:00
)
if op_code == "0":
2022-07-04 17:59:09 +02:00
q.add_log_cmd("PLOC Supervisor: Dump MRAM")
command = pack_mram_dump_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
2021-08-31 11:17:01 +02:00
2022-07-04 17:59:09 +02:00
def pack_mram_dump_cmd(object_id: bytes) -> bytearray:
2021-08-31 11:17:01 +02:00
start = int(input("Start address: 0x"), 16)
end = int(input("End address: 0x"), 16)
2023-01-16 14:13:06 +01:00
command = object_id + struct.pack("!I", ActionId.DUMP_MRAM)
2022-01-18 14:03:56 +01:00
command = command + struct.pack("!I", start)
command = command + struct.pack("!I", end)
2022-07-04 17:59:09 +02:00
return bytearray(command)