eive-tmtc/pus_tc/ploc_memory_dumper.py

42 lines
1.3 KiB
Python
Raw Normal View History

2021-08-31 11:17:01 +02:00
# -*- 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