eive-tmtc/pus_tc/devs/ploc_memory_dumper.py

40 lines
1.2 KiB
Python

# -*- 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 spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.util import ObjectIdU32
class ActionIds:
DUMP_MRAM = 1
def pack_ploc_memory_dumper_cmd(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
q.add_log_cmd(
f"Testing PLOC memory dumper with object id: {object_id.as_hex_string}"
)
if op_code == "0":
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))
def pack_mram_dump_cmd(object_id: bytes) -> bytearray:
start = int(input("Start address: 0x"), 16)
end = int(input("End address: 0x"), 16)
command = object_id + struct.pack("!I", ActionIds.DUMP_MRAM)
command = command + struct.pack("!I", start)
command = command + struct.pack("!I", end)
return bytearray(command)