ploc mpsoc commands
This commit is contained in:
@ -9,61 +9,68 @@
|
||||
import struct
|
||||
|
||||
from tmtccmd.config.definitions import QueueCommands
|
||||
|
||||
from tmtccmd.utility.logger import get_console_logger
|
||||
from tmtccmd.tc.packer import TcQueueT
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
|
||||
LOGGER = get_console_logger()
|
||||
|
||||
class PlocTestProcedure:
|
||||
"""
|
||||
@brief Use this class to define the tests to perform for the PLOC.
|
||||
@details Setting all to True will run all tests.
|
||||
Setting all to False will only run the tests set to True.
|
||||
"""
|
||||
MANUAL_INPUT = "3"
|
||||
|
||||
all = False
|
||||
test_tc_mem_write = False
|
||||
test_tc_mem_read = True
|
||||
flash_write_dict = {
|
||||
"1": ["q7s test file", "/mnt/sd0/ploc-mpsoc/flashwrite.bin"],
|
||||
"2": ["te0720-1cfa test file", "/mnt/sd0/ploc-mpsoc/flashwrite.bin"],
|
||||
MANUAL_INPUT: ["manual input", ""],
|
||||
}
|
||||
|
||||
|
||||
class PlocActionIds:
|
||||
tc_mem_write = bytearray([0x0, 0x0, 0x0, 0x1])
|
||||
tc_mem_read = bytearray([0x0, 0x0, 0x0, 0x2])
|
||||
class CommandIds:
|
||||
tc_mem_write = 1
|
||||
tc_mem_read = 2
|
||||
flash_write = 3
|
||||
|
||||
|
||||
class PlocReplyIds:
|
||||
tm_mem_read_report = 6
|
||||
|
||||
|
||||
def pack_ploc_mpsoc_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
|
||||
def pack_ploc_mpsoc_commands(
|
||||
object_id: bytearray, tc_queue: TcQueueT, op_code: str
|
||||
) -> TcQueueT:
|
||||
tc_queue.appendleft(
|
||||
(QueueCommands.PRINT, "Testing PLOC MPSoC with object id: 0x" + object_id.hex())
|
||||
(
|
||||
QueueCommands.PRINT,
|
||||
"Generate command for PLOC MPSoC with object id: 0x" + object_id.hex(),
|
||||
)
|
||||
)
|
||||
|
||||
if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_write:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Write Test"))
|
||||
memory_address = int(input("PLOC Tc Mem Write: Type memory address: 0x"), 16)
|
||||
memory_data = int(input("PLOC Tc Mem Write: Type memory data: 0x"), 16)
|
||||
if op_code == "0":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: TC mem write test"))
|
||||
memory_address = int(input("PLOC MPSoC: Tc Mem Write: Type memory address: 0x"), 16)
|
||||
memory_data = int(input("PLOC MPSoC: Tc Mem Write: Type memory data: 0x"), 16)
|
||||
# TODO: implement variable length mem write command
|
||||
mem_len = 1 # 1 32-bit word
|
||||
command = generate_write_mem_command(
|
||||
object_id, struct.pack("!I", memory_address), memory_data
|
||||
object_id, memory_address, memory_data, mem_len
|
||||
)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_read:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Read Test"))
|
||||
memory_address = int(input("PLOC Tc Mem Read: Type memory address: 0x"), 16)
|
||||
command = (
|
||||
object_id + PlocActionIds.tc_mem_read + struct.pack("!I", memory_address)
|
||||
)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
||||
elif op_code == "1":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: TC mem read test"))
|
||||
command = prepare_mem_read_command(object_id)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
elif op_code == "2":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: Flash write"))
|
||||
command = prepare_flash_write_cmd(object_id)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
return tc_queue
|
||||
|
||||
|
||||
def generate_write_mem_command(
|
||||
object_id: bytearray, memory_address: bytes, memory_data: int
|
||||
object_id: bytearray, memory_address: int, memory_data: int, mem_len: int
|
||||
) -> bytearray:
|
||||
"""This function generates the command to write to a memory address within the PLOC
|
||||
@param object_id The object id of the PlocHandler
|
||||
@ -71,9 +78,37 @@ def generate_write_mem_command(
|
||||
@param memory_data The data to write to the memory address specified by the bytearray memory_address.
|
||||
"""
|
||||
command = (
|
||||
object_id
|
||||
+ PlocActionIds.tc_mem_write
|
||||
+ memory_address
|
||||
+ struct.pack("!I", memory_data)
|
||||
object_id
|
||||
+ struct.pack('!I', CommandIds.tc_mem_write)
|
||||
+ struct.pack('!I', memory_address)
|
||||
+ struct.pack('!H', mem_len)
|
||||
+ struct.pack("!I", memory_data)
|
||||
)
|
||||
return command
|
||||
|
||||
|
||||
def prepare_mem_read_command(object_id: bytearray) -> bytearray:
|
||||
memory_address = int(input("PLOC MPSoC Tc Mem Read: Type memory address: 0x"), 16)
|
||||
num_words = int(input("PLOC MPSoC specify number of words (32-bit) to read: "))
|
||||
command = (
|
||||
object_id + struct.pack('!I', CommandIds.tc_mem_read) + struct.pack("!I", memory_address) + struct.pack(
|
||||
'!H', num_words)
|
||||
)
|
||||
return command
|
||||
|
||||
|
||||
def prepare_flash_write_cmd(object_id: bytearray) -> bytearray:
|
||||
file = get_flash_write_file()
|
||||
command = object_id + struct.pack('I', CommandIds.flash_write) + bytearray(file, 'utf-8')
|
||||
return command
|
||||
|
||||
|
||||
def get_flash_write_file() -> str:
|
||||
LOGGER.info("Specify json file")
|
||||
input_helper = InputHelper(json_dict)
|
||||
key = input_helper.get_key()
|
||||
if key == MANUAL_INPUT:
|
||||
file = input("Ploc MPSoC: Specify absolute name of flash write file: ")
|
||||
else:
|
||||
file = json_dict[key][1]
|
||||
return file
|
||||
|
@ -75,7 +75,7 @@ class SupvHkIds:
|
||||
BOOT_STATUS_REPORT = 53
|
||||
|
||||
|
||||
def pack_ploc_supv_test_into(
|
||||
def pack_ploc_supv_commands(
|
||||
object_id: bytearray, tc_queue: TcQueueT, op_code: str
|
||||
) -> TcQueueT:
|
||||
tc_queue.appendleft(
|
||||
|
@ -15,6 +15,7 @@ from tmtccmd.tc.service_200_mode import pack_mode_data, Modes
|
||||
from tmtccmd.utility.logger import get_console_logger
|
||||
from utility.input_helper import InputHelper
|
||||
|
||||
|
||||
LOGGER = get_console_logger()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user