162 lines
8.7 KiB
Python
162 lines
8.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
@file tmtcc_tc_p60dock.py
|
|
@brief P60 Dock tests
|
|
@author J. Meier
|
|
@date 13.12.2020
|
|
"""
|
|
from tmtccmd.config.definitions import QueueCommands
|
|
from tmtccmd.tc.packer import TcQueueT
|
|
from tmtccmd.ecss.tc import PusTelecommand
|
|
from gomspace.gomspace_common import *
|
|
|
|
|
|
class P60DockTestProcedure:
|
|
"""
|
|
@brief Use this class to define the tests to perform for the P60Dock.
|
|
@details Setting all to True will run all tests.
|
|
Setting all to False will only run the tests set to True.
|
|
"""
|
|
all = False
|
|
reboot = False
|
|
read_gnd_wdt = False
|
|
gnd_wdt_reset = False
|
|
ping = False
|
|
channel_3_off = False # pdu2
|
|
read_temperature1 = True
|
|
read_channel_3_state = False # pdu2
|
|
read_cur_lu_lim_0 = False
|
|
channel_3_on = False # pdu2
|
|
invalid_table_id_test = False # Test to check if software properly handles invalid table ids
|
|
invalid_address_test = False # Test to check if software properly handles invalid addresses
|
|
invalid_parameter_size_test = False
|
|
|
|
|
|
class P60DockConfigTable:
|
|
out_en_0 = TableEntry(bytearray([0x00, 0x68]), TableEntry.uint8_size) # ACU
|
|
out_en_1 = TableEntry(bytearray([0x00, 0x69]), TableEntry.uint8_size) # PDU1
|
|
out_en_2 = TableEntry(bytearray([0x00, 0x6A]), TableEntry.uint8_size)
|
|
out_en_3 = TableEntry(bytearray([0x00, 0x6B]), TableEntry.uint8_size) # PDU2
|
|
# When channel consumes more than cur_lu_lim, channel is turned of immediately
|
|
cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xF8]), TableEntry.uint16_size)
|
|
|
|
|
|
class P60DockHkTable:
|
|
temperature1 = TableEntry(bytearray([0x00, 0x44]), TableEntry.uint16_size)
|
|
temperature2 = TableEntry(bytearray([0x00, 0x46]), TableEntry.uint16_size)
|
|
# Ground WDT value (remaining seconds until reboot)
|
|
wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size)
|
|
|
|
|
|
def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.reboot:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Reboot"))
|
|
command = pack_reboot_command(object_id)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_gnd_wdt:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Reading ground watchdog timer value"))
|
|
command = pack_get_param_command(
|
|
object_id, TableIds.hk, P60DockHkTable.wdt_gnd_left.parameter_address,
|
|
P60DockHkTable.wdt_gnd_left.parameter_size
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.gnd_wdt_reset:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing ground watchdog reset"))
|
|
command = pack_gnd_wdt_reset_command(object_id)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.ping:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Ping"))
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
command = pack_ping_command(object_id, ping_data)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_off:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 off"))
|
|
parameter = 0 # set channel off
|
|
command = pack_set_param_command(object_id, P60DockConfigTable.out_en_3.parameter_address,
|
|
P60DockConfigTable.out_en_3.parameter_size, parameter)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_temperature1:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing temperature reading"))
|
|
command = pack_get_param_command(
|
|
object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address,
|
|
P60DockHkTable.temperature1.parameter_size
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
|
|
tc_queue.appendleft((QueueCommands.PRINT,
|
|
"P60 Dock: Testing Output Channel 3 state (PDU2)"))
|
|
command = pack_get_param_command(object_id, TableIds.config, P60DockConfigTable.out_en_3.parameter_address,
|
|
P60DockConfigTable.out_en_3.parameter_size)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_cur_lu_lim_0:
|
|
tc_queue.appendleft((QueueCommands.PRINT,
|
|
"P60 Dock: Reading current limit value of output channel 0"))
|
|
command = pack_get_param_command(
|
|
object_id, TableIds.config, P60DockConfigTable.cur_lu_lim_0.parameter_address,
|
|
P60DockConfigTable.cur_lu_lim_0.parameter_size
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 on"))
|
|
parameter = 1 # set channel on
|
|
command = pack_set_param_command(object_id, P60DockConfigTable.out_en_3.parameter_address,
|
|
P60DockConfigTable.out_en_3.parameter_size, parameter)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_table_id_test:
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing invalid table id handling"))
|
|
table_id_invalid = 5
|
|
command = pack_get_param_command(
|
|
object_id, table_id_invalid, P60DockHkTable.temperature1.parameter_address,
|
|
P60DockHkTable.temperature1.parameter_size
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_address_test:
|
|
tc_queue.appendleft((QueueCommands.PRINT,
|
|
"P60 Dock: Testing invalid address handling in get param command"))
|
|
invalid_address = bytearray([0x01, 0xF4])
|
|
command = pack_get_param_command(object_id, TableIds.hk, invalid_address,
|
|
P60DockHkTable.temperature1.parameter_size)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=29, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
tc_queue.appendleft((QueueCommands.PRINT,
|
|
"P60 Dock: Testing invalid address handling in set param command"))
|
|
invalid_address = bytearray([0x01, 0xF4])
|
|
parameter_size = 2
|
|
parameter = 1
|
|
command = pack_set_param_command(object_id, invalid_address, parameter_size, parameter)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_parameter_size_test:
|
|
tc_queue.appendleft(
|
|
(QueueCommands.PRINT,
|
|
"P60 Dock: Testing handling of invalid parameter sizes in get-param command")
|
|
)
|
|
invalid_size = 5
|
|
command = pack_get_param_command(
|
|
object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address, invalid_size
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
tc_queue.appendleft(
|
|
(QueueCommands.PRINT,
|
|
"P60 Dock: Testing handling of invalid parameter size in set-param command")
|
|
)
|
|
parameter = 1
|
|
command = pack_set_param_command(
|
|
object_id, P60DockConfigTable.out_en_3.parameter_address, invalid_size, parameter
|
|
)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
return tc_queue
|