eive-tmtc/pus_tc/ploc_upater.py

74 lines
2.7 KiB
Python
Raw Normal View History

2021-08-07 14:34:26 +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
from tmtccmd.tc.packer import TcQueueT
from tmtccmd.ecss.tc import PusTelecommand
from tmtccmd.utility.logger import get_console_logger
LOGGER = get_console_logger()
latchup_id_dict = {
"0": "0.85V",
"1": "1.8V",
"2": "MISC",
"3": "3.3V",
"4": "NVM_4XO",
"5": "MISSION",
"6": "SAFECOTS"
}
class UpdaterActionIds:
UPDATE_NVM0_A = 0
UPDATE_NVM0_B = 1
UPDATE_NVM1_A = 2
UPDATE_NVM1_B = 3
class ImagePathDefs:
imageNvm0A = "/mnt/sd0/ploc/updateNvm0A.bin"
2021-08-08 15:02:29 +02:00
imageNvm0B = "/mnt/sd0/ploc/updateNvm0B.bin"
imageNvm1A = "/mnt/sd0/ploc/updateNvm1A.bin"
imageNvm1B = "/mnt/sd0/ploc/updateNvm1B.bin"
2021-08-07 14:34:26 +02:00
def pack_ploc_updater_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT:
tc_queue.appendleft(
(QueueCommands.PRINT,
"Testing PLOC updater with object id: 0x" + object_id.hex())
)
if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update partition A on NVM0"))
command = object_id + struct.pack('!I', UpdaterActionIds.UPDATE_NVM0_A) + \
bytearray(ImagePathDefs.imageNvm0A, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
2021-08-08 15:02:29 +02:00
if op_code == "1":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update partition B on NVM0"))
command = object_id + struct.pack('!I', UpdaterActionIds.UPDATE_NVM0_B) + \
bytearray(ImagePathDefs.imageNvm0B, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "2":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update partition A on NVM1"))
command = object_id + struct.pack('!I', UpdaterActionIds.UPDATE_NVM1_A) + \
bytearray(ImagePathDefs.imageNvm1A, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "3":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update partition B on NVM1"))
command = object_id + struct.pack('!I', UpdaterActionIds.UPDATE_NVM1_B) + \
bytearray(ImagePathDefs.imageNvm1B, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())