2020-12-29 11:29:03 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file tmtcc_tc_pdu2.py
|
|
|
|
@brief PDU2 tests
|
|
|
|
@author J. Meier
|
|
|
|
@date 17.12.2020
|
|
|
|
"""
|
|
|
|
|
|
|
|
from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT
|
|
|
|
from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand
|
|
|
|
from gomspace.gomspace_common import *
|
|
|
|
from gomspace.gomspace_pdu_definitions import *
|
|
|
|
from pus_tc.tmtcc_tc_p60dock import P60DockConfigTable
|
|
|
|
|
|
|
|
|
|
|
|
class PDU2TestProcedure:
|
|
|
|
"""
|
|
|
|
@brief Use this class to define the tests to perform for the PDU2.
|
|
|
|
@details Setting all to True will run all tests.
|
|
|
|
Setting all to False will only run the tests set to True.
|
|
|
|
"""
|
2021-02-06 16:35:53 +01:00
|
|
|
all = False
|
2020-12-29 11:29:03 +01:00
|
|
|
reboot = False
|
|
|
|
read_gnd_wdt = False
|
|
|
|
gnd_wdt_reset = False
|
|
|
|
ping = False
|
|
|
|
channel_2_off = False # TCS Heater
|
|
|
|
read_temperature = False
|
|
|
|
read_channel_2_state = False # TCS Heater
|
|
|
|
read_cur_lu_lim_0 = False # OBC
|
|
|
|
channel_2_on = False # TCS Heater
|
|
|
|
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
|
2021-02-06 16:35:53 +01:00
|
|
|
invalid_parameter_size_test = False
|
|
|
|
request_hk_table = True
|
2020-12-29 11:29:03 +01:00
|
|
|
|
|
|
|
|
2021-02-06 16:35:53 +01:00
|
|
|
def pack_pdu2_test_into(pdu2_object_id: bytearray, p60dock_object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
|
2020-12-29 11:29:03 +01:00
|
|
|
tc_queue.appendleft(("print", "Testing PDU2"))
|
|
|
|
|
|
|
|
tc_queue.appendleft(("print", "P60 Dock: Enabling PDU2"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_set_param_command(p60dock_object_id, P60DockConfigTable.out_en_3.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
P60DockConfigTable.out_en_3.parameter_size, Channel.on)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Reboot"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_reboot_command(pdu2_object_id)
|
2020-12-29 11:29:03 +01:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Reading ground watchdog timer value"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_get_param_command(pdu2_object_id, TableIds.hk, PDUHkTable.wdt_gnd_left.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUHkTable.wdt_gnd_left.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Testing ground watchdog reset"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_gnd_wdt_reset_command(pdu2_object_id)
|
2020-12-29 11:29:03 +01:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.ping:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Ping Test"))
|
|
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_ping_command(pdu2_object_id, ping_data)
|
2020-12-29 11:29:03 +01:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Testing setting output channel 2 on (TCS Heater)"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_set_param_command(pdu2_object_id, PDUConfigTable.out_en_2.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUConfigTable.out_en_2.parameter_size, Channel.on)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-02-06 16:35:53 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature:
|
2020-12-29 11:29:03 +01:00
|
|
|
tc_queue.appendleft(("print", "PDU2: Testing temperature reading"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_get_param_command(pdu2_object_id, TableIds.hk, PDUHkTable.temperature.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUHkTable.temperature.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Reading output channel 2 state (TCS Heater)"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_get_param_command(pdu2_object_id, TableIds.config, PDUConfigTable.out_en_2.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUConfigTable.out_en_2.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Reading current limit value of output channel 0 (OBC)"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_get_param_command(pdu2_object_id, TableIds.config, PDUConfigTable.cur_lu_lim_0.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUConfigTable.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 PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Testing setting output channel 2 off"))
|
2021-02-06 16:35:53 +01:00
|
|
|
command = pack_set_param_command(pdu2_object_id, PDUConfigTable.out_en_2.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
PDUConfigTable.out_en_2.parameter_size, Channel.off)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-02-06 16:35:53 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table:
|
|
|
|
tc_queue.appendleft(("print", "PDU2: Requesting housekeeping table"))
|
|
|
|
command = pack_request_full_hk_table_command(pdu2_object_id)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2020-12-29 11:29:03 +01:00
|
|
|
return tc_queue
|