eive-tmtc/pus_tc/ploc_mpsoc.py

69 lines
2.6 KiB
Python
Raw Normal View History

2021-04-11 11:08:52 +02:00
# -*- coding: utf-8 -*-
"""
2021-07-11 14:29:11 +02:00
@file ploc_mpsoc.py
@brief Tests for commanding the MPSoC of the PLOC.
The MPSoC is programmed by the ILH.
2021-04-11 11:08:52 +02:00
@author J. Meier
2021-07-11 14:29:11 +02:00
@date 06.03.2021
2021-04-11 11:08:52 +02:00
"""
import struct
2021-06-12 13:49:25 +02:00
from tmtccmd.config.definitions import QueueCommands
2021-04-11 11:08:52 +02:00
from tmtccmd.tc.packer import TcQueueT
2021-04-24 13:27:57 +02:00
from tmtccmd.ecss.tc import PusTelecommand
2021-04-11 11:08:52 +02:00
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.
"""
all = False
test_tc_mem_write = False
test_tc_mem_read = True
class PlocActionIds:
2021-04-24 13:27:57 +02:00
tc_mem_write = bytearray([0x0, 0x0, 0x0, 0x1])
tc_mem_read = bytearray([0x0, 0x0, 0x0, 0x2])
class PlocReplyIds:
tm_mem_read_report = 6
2021-04-11 11:08:52 +02:00
2021-07-11 14:29:11 +02:00
def pack_ploc_mpsoc_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
2021-04-11 11:08:52 +02:00
tc_queue.appendleft(
(QueueCommands.PRINT,
2021-07-11 14:29:11 +02:00
"Testing PLOC MPSoC with object id: 0x" + object_id.hex())
2021-04-11 11:08:52 +02:00
)
if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_write:
tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Write Test"))
2021-04-27 17:38:52 +02:00
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)
command = generate_write_mem_command(object_id, struct.pack('!I', memory_address), memory_data)
2021-04-11 11:08:52 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
2021-04-24 13:27:57 +02:00
if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_read:
2021-04-11 11:08:52 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Read Test"))
2021-04-27 17:38:52 +02:00
memory_address = int(input("PLOC Tc Mem Read: Type memory address: 0x"), 16)
2021-04-24 13:27:57 +02:00
command = object_id + PlocActionIds.tc_mem_read + struct.pack('!I', memory_address)
2021-04-11 11:08:52 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
2021-04-27 17:38:52 +02:00
def generate_write_mem_command(object_id: bytearray, memory_address: bytearray, memory_data: int) -> bytearray:
2021-04-11 11:08:52 +02:00
""" This function generates the command to write to a memory address within the PLOC
@param object_id The object id of the PlocHandler
@param memory_address The PLOC memory address where to write to.
@param memory_data The data to write to the memory address specified by the bytearray memory_address.
"""
2021-04-24 13:27:57 +02:00
command = object_id + PlocActionIds.tc_mem_write + memory_address + struct.pack('!I', memory_data)
return command