eive-tmtc/pus_tc/devs/pdu2.py
2022-08-25 09:55:34 +02:00

139 lines
5.2 KiB
Python

# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_pdu2.py
@brief PDU2 tests
@details PDU2 is mounted on the X4 slot of the P60 dock
@author J. Meier
@date 17.12.2020
"""
from pus_tc.devs.common_power import pdu2_cmds, pdu2_req_hk_cmds
from gomspace.gomspace_common import *
from gomspace.gomspace_pdu_definitions import *
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.
"""
all = False
reboot = False
read_gnd_wdt = False
gnd_wdt_reset = False
ping = False
channel_2_off = False # Reaction wheels 5V
read_temperature = False
read_channel_2_state = False # Reaction wheels 5V
read_cur_lu_lim_0 = False # OBC
channel_2_on = False # Reaction wheels 5V
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
request_hk_table = False
def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
q.add_log_cmd("Testing PDU2")
objb = object_id.as_bytes
pdu2_cmds(q, op_code)
pdu2_req_hk_cmds(q, op_code)
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
q.add_log_cmd(f"PDU2: {GsInfo.PRINT_SWITCH_V_I}")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
)
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
q.add_log_cmd("PDU2: Print Latchups")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
)
if op_code in GomspaceOpCodes.SET_PARAM:
q.add_log_cmd(f"PDU2: {GsInfo.SET_PARAMETER}")
prompt_and_pack_set_param_command(q, object_id)
if op_code in GomspaceOpCodes.GET_PARAM:
q.add_log_cmd(f"PDU2: {GsInfo.GET_PARAMETER}")
prompt_and_pack_get_param_command(q, object_id)
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
q.add_log_cmd("PDU2: Reboot")
q.add_pus_tc(pack_reboot_command(object_id))
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
q.add_log_cmd("PDU2: Reading ground watchdog timer value")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
PduHkTable.wdt_gnd_left.parameter_address,
PduHkTable.wdt_gnd_left.parameter_size,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
q.add_log_cmd("PDU2: Testing ground watchdog reset")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
if PDU2TestProcedure.all or PDU2TestProcedure.ping:
q.add_log_cmd("PDU2: Ping Test")
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
q.add_pus_tc(pack_ping_command(object_id, ping_data))
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on:
q.add_log_cmd("PDU2: Testing setting output channel 2 on (TCS Heater)")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
Channel.on,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature:
q.add_log_cmd("PDU2: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
PduHkTable.temperature.parameter_address,
PduHkTable.temperature.parameter_size,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
q.add_log_cmd("PDU2: Reading output channel 2 state (TCS Heater)")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
q.add_log_cmd("PDU2: Reading current limit value of output channel 0 (OBC)")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
PduConfigTable.cur_lu_lim_0.parameter_address,
PduConfigTable.cur_lu_lim_0.parameter_size,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off:
q.add_log_cmd("PDU2: Testing setting output channel 2 off")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
Channel.off,
)
)
if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table:
q.add_log_cmd("PDU2: Requesting housekeeping table")
q.add_pus_tc(pack_request_full_hk_table_command(object_id))