2021-07-11 14:29:11 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file ploc_supervisor.py
|
|
|
|
@brief Tests for commanding the supervisor of the PLOC.
|
|
|
|
The supervisor is programmed by Thales.
|
|
|
|
@author J. Meier
|
|
|
|
@date 10.07.2021
|
|
|
|
"""
|
|
|
|
import struct
|
|
|
|
|
|
|
|
from tmtccmd.config.definitions import QueueCommands
|
|
|
|
|
2021-07-24 14:58:47 +02:00
|
|
|
from tmtccmd.tc.packer import TcQueueT
|
2021-07-11 14:29:11 +02:00
|
|
|
from tmtccmd.ecss.tc import PusTelecommand
|
|
|
|
|
|
|
|
|
|
|
|
class SupvActionIds:
|
|
|
|
HK_REPORT = 1
|
2021-07-23 13:40:27 +02:00
|
|
|
RESTART_MPSOC = 2
|
|
|
|
START_MPSOC = 3
|
|
|
|
SHUTWOWN_MPSOC = 4
|
|
|
|
SEL_MPSOC_BOOT_IMAGE = 5
|
|
|
|
SET_BOOT_TIMEOUT = 6
|
|
|
|
SET_MAX_RESTART_TRIES = 7
|
|
|
|
RESET_MPSOC = 8
|
|
|
|
SET_TIME_REF = 9
|
|
|
|
DISABLE_HK = 10
|
2021-07-25 17:56:36 +02:00
|
|
|
GET_BOOT_STATUS_REPORT = 11
|
2021-07-26 16:29:54 +02:00
|
|
|
UPDATE_AVAILABLE = 12
|
|
|
|
WATCHDOGS_ENABLE = 13
|
2021-07-11 14:29:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SupvHkIds:
|
|
|
|
HK_REPORT = 52
|
2021-07-25 17:56:36 +02:00
|
|
|
BOOT_STATUS_REPORT = 53
|
2021-07-11 14:29:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
def pack_ploc_supv_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT:
|
|
|
|
tc_queue.appendleft(
|
|
|
|
(QueueCommands.PRINT,
|
|
|
|
"Testing PLOC Supervisor with object id: 0x" + object_id.hex())
|
|
|
|
)
|
|
|
|
|
|
|
|
if op_code == "3":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: TC Get Hk Report"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.HK_REPORT)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-07-23 13:40:27 +02:00
|
|
|
elif op_code == "4":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Restart MPSoC"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.RESTART_MPSOC)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "5":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Start MPSoC"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.START_MPSOC)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "6":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Shutdown MPSoC"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.SHUTWOWN_MPSOC)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "7":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Select MPSoC boot image"))
|
|
|
|
mem = int(input("MEM (NVM0 - 0 or NVM1 - 1):"))
|
|
|
|
bp0 = int(input("BP0 (0 or 1):"))
|
|
|
|
bp1 = int(input("BP1 (0 or 1):"))
|
|
|
|
bp2 = int(input("BP2 (0 or 1):"))
|
|
|
|
command = pack_sel_boot_image_cmd(object_id, mem, bp0, bp1, bp2)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "8":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set max restart tries"))
|
|
|
|
restart_tries = int(input("Set maximum restart tries:"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.SET_MAX_RESTART_TRIES) + struct.pack('!B', restart_tries)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "9":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Reset MPSoC"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.RESET_MPSOC)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "10":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set time reference"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.SET_TIME_REF)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "11":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set boot timeout"))
|
|
|
|
boot_timeout = int(input("Specify boot timeout [ms]:"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.SET_BOOT_TIMEOUT) + struct.pack('!I', boot_timeout)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "12":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Disable HK"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.DISABLE_HK)
|
2021-07-25 17:56:36 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=29, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "13":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Request boot status report"))
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.GET_BOOT_STATUS_REPORT)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
|
2021-07-23 13:40:27 +02:00
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-07-26 16:29:54 +02:00
|
|
|
elif op_code == "14":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update available"))
|
|
|
|
command = pack_update_available_cmd(object_id)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
elif op_code == "15":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Watchdogs Enable"))
|
|
|
|
command = pack_watchdogs_enable_cmd(object_id)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-07-11 14:29:11 +02:00
|
|
|
|
|
|
|
return tc_queue
|
2021-07-23 13:40:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
def pack_sel_boot_image_cmd(object_id: bytearray, mem: int, bp0: int, bp1: int, bp2: int) -> bytearray:
|
|
|
|
""" This function can be used to generate the command to select the image from which the MPSoC will boot
|
|
|
|
@param object_id The object id of the PLOC supervisor handler.
|
|
|
|
@param mem The memory from which the MPSoC shall boot (NVM0 - 0, NVM1 - 1)
|
|
|
|
@param bp0 Partition pin 0
|
|
|
|
@param bp1 Partition pin 1
|
|
|
|
@param bp2 Partition pin 2
|
|
|
|
"""
|
|
|
|
command = bytearray()
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.SEL_MPSOC_BOOT_IMAGE)
|
|
|
|
command = command + struct.pack('!B', mem)
|
|
|
|
command = command + struct.pack('!B', bp0)
|
|
|
|
command = command + struct.pack('!B', bp1)
|
|
|
|
command = command + struct.pack('!B', bp2)
|
|
|
|
return command
|
2021-07-26 16:29:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def pack_update_available_cmd(object_id: bytearray) -> bytearray:
|
|
|
|
"""
|
|
|
|
@brief This function packs the udpate availabe command.
|
|
|
|
@param object_id The object id of the PLOC supervisor handler.
|
|
|
|
"""
|
|
|
|
image_select = 1
|
|
|
|
image_partition = 0
|
|
|
|
image_size = 222
|
|
|
|
image_crc = 0x0
|
|
|
|
number_of_packets = 150
|
|
|
|
command = bytearray()
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.UPDATE_AVAILABLE)
|
|
|
|
command = command + struct.pack('!B', image_select)
|
|
|
|
command = command + struct.pack('!B', image_partition)
|
|
|
|
command = command + struct.pack('!I', image_size)
|
|
|
|
command = command + struct.pack('!I', image_crc)
|
|
|
|
command = command + struct.pack('!I', number_of_packets)
|
|
|
|
return command
|
|
|
|
|
|
|
|
|
|
|
|
def pack_watchdogs_enable_cmd(object_id: bytearray) -> bytearray:
|
|
|
|
"""
|
|
|
|
@brief This function packs the command to enable or disable watchdogs on the PLOC.
|
|
|
|
@param object_id The object id of the PLOC supervisor handler.
|
|
|
|
@note Enable = 1, Disable = 0
|
|
|
|
"""
|
|
|
|
watchdog_ps = 1
|
|
|
|
watchdog_pl = 1
|
|
|
|
watchdog_int = 0
|
|
|
|
command = bytearray()
|
|
|
|
command = object_id + struct.pack('!I', SupvActionIds.WATCHDOGS_ENABLE)
|
|
|
|
command = command + struct.pack('!B', watchdog_ps)
|
|
|
|
command = command + struct.pack('!B', watchdog_pl)
|
|
|
|
command = command + struct.pack('!B', watchdog_int)
|
|
|
|
return command
|