2020-12-29 11:29:03 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file tmtcc_tc_pdu2.py
|
|
|
|
@brief PDU2 tests
|
2021-12-02 08:01:18 +01:00
|
|
|
@details PDU2 is mounted on the X4 slot of the P60 dock
|
2020-12-29 11:29:03 +01:00
|
|
|
@author J. Meier
|
|
|
|
@date 17.12.2020
|
|
|
|
"""
|
2022-08-08 16:32:18 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
2022-05-05 16:15:53 +02:00
|
|
|
from tmtccmd.tc.pus_3_fsfw_hk import (
|
2022-04-12 16:35:34 +02:00
|
|
|
generate_one_hk_command,
|
|
|
|
generate_one_diag_command,
|
|
|
|
make_sid,
|
|
|
|
)
|
2022-08-11 18:10:15 +02:00
|
|
|
from pus_tc.devs.common_power import pdu2_cmds, pdu2_req_hk_cmds
|
2020-12-29 11:29:03 +01:00
|
|
|
from gomspace.gomspace_common import *
|
|
|
|
from gomspace.gomspace_pdu_definitions import *
|
2022-03-14 10:03:50 +01:00
|
|
|
from config.object_ids import PDU_2_HANDLER_ID
|
2021-09-07 14:51:50 +02:00
|
|
|
|
|
|
|
|
2020-12-29 11:29:03 +01:00
|
|
|
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.
|
|
|
|
"""
|
2022-01-18 14:03:56 +01:00
|
|
|
|
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
|
2021-02-11 08:18:42 +01:00
|
|
|
channel_2_off = False # Reaction wheels 5V
|
2021-09-08 13:43:47 +02:00
|
|
|
read_temperature = False
|
2021-02-11 08:18:42 +01:00
|
|
|
read_channel_2_state = False # Reaction wheels 5V
|
2021-03-19 17:50:09 +01:00
|
|
|
read_cur_lu_lim_0 = False # OBC
|
2021-02-11 08:18:42 +01:00
|
|
|
channel_2_on = False # Reaction wheels 5V
|
2022-01-18 14:03:56 +01:00
|
|
|
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
|
2021-02-11 08:18:42 +01:00
|
|
|
request_hk_table = False
|
2020-12-29 11:29:03 +01:00
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("Testing PDU2")
|
2022-05-23 11:24:55 +02:00
|
|
|
objb = object_id.as_bytes
|
2022-08-11 18:10:15 +02:00
|
|
|
pdu2_cmds(q, op_code)
|
|
|
|
pdu2_req_hk_cmds(q, op_code)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
|
2022-08-11 18:10:15 +02:00
|
|
|
q.add_log_cmd(f"PDU2: {GsInfo.PRINT_SWITCH_V_I}")
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-08-22 11:47:12 +02:00
|
|
|
make_fsfw_action_cmd(
|
2022-07-04 15:22:53 +02:00
|
|
|
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
|
|
|
|
)
|
2021-09-07 14:51:50 +02:00
|
|
|
)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Print Latchups")
|
|
|
|
q.add_pus_tc(
|
2022-08-22 11:47:12 +02:00
|
|
|
make_fsfw_action_cmd(
|
2022-07-04 15:22:53 +02:00
|
|
|
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
|
|
|
|
)
|
2022-03-14 14:46:00 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Reboot")
|
|
|
|
q.add_pus_tc(pack_reboot_command(object_id))
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Reading ground watchdog timer value")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
|
|
|
TableIds.hk,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduHkTable.wdt_gnd_left.parameter_address,
|
|
|
|
PduHkTable.wdt_gnd_left.parameter_size,
|
2022-07-04 15:22:53 +02:00
|
|
|
)
|
2021-09-07 14:51:50 +02:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Testing ground watchdog reset")
|
|
|
|
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.ping:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Ping Test")
|
2020-12-29 11:29:03 +01:00
|
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(pack_ping_command(object_id, ping_data))
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Testing setting output channel 2 on (TCS Heater)")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_set_param_command(
|
|
|
|
objb,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduConfigTable.out_en_2.parameter_address,
|
|
|
|
PduConfigTable.out_en_2.parameter_size,
|
2022-07-04 15:22:53 +02:00
|
|
|
Channel.on,
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
|
|
|
)
|
2021-02-06 16:35:53 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Testing temperature reading")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
|
|
|
TableIds.hk,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduHkTable.temperature.parameter_address,
|
|
|
|
PduHkTable.temperature.parameter_size,
|
2022-07-04 15:22:53 +02:00
|
|
|
)
|
2021-09-07 14:51:50 +02:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Reading output channel 2 state (TCS Heater)")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
|
|
|
TableIds.config,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduConfigTable.out_en_2.parameter_address,
|
|
|
|
PduConfigTable.out_en_2.parameter_size,
|
2022-07-04 15:22:53 +02:00
|
|
|
)
|
2021-09-07 14:51:50 +02:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
|
2022-07-04 15:22:53 +02:00
|
|
|
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,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduConfigTable.cur_lu_lim_0.parameter_address,
|
|
|
|
PduConfigTable.cur_lu_lim_0.parameter_size,
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2021-09-07 14:51:50 +02:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Testing setting output channel 2 off")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_set_param_command(
|
|
|
|
objb,
|
2022-08-11 14:45:24 +02:00
|
|
|
PduConfigTable.out_en_2.parameter_address,
|
|
|
|
PduConfigTable.out_en_2.parameter_size,
|
2022-07-04 15:22:53 +02:00
|
|
|
Channel.off,
|
|
|
|
)
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2021-02-06 16:35:53 +01:00
|
|
|
if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("PDU2: Requesting housekeeping table")
|
|
|
|
q.add_pus_tc(pack_request_full_hk_table_command(object_id))
|