eive-tmtc/pus_tc/devs/pdu2.py

338 lines
12 KiB
Python
Raw Normal View History

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
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
generate_one_diag_command,
make_sid,
)
2020-12-29 11:29:03 +01:00
from gomspace.gomspace_common import *
from gomspace.gomspace_pdu_definitions import *
from config.object_ids import PDU_2_HANDLER_ID
2021-09-07 14:51:50 +02:00
2022-08-11 14:45:24 +02:00
class Pdu2OpCodes:
ACS_SIDE_B_ON = ["acs-b-on", "1"]
ACS_SIDE_B_OFF = ["acs-b-off", "2"]
SUS_REDUNDANT_ON = ["sus-red-on", "3"]
SUS_REDUNDANT_OFF = ["sus-red-off", "4"]
RW_ON = ["rw-on", "5"]
RW_OFF = ["rw-off", "6"]
PL_PCDU_VBAT_NOM_ON = ["plpcdu-vbat-nom-on", "7"]
PL_PCDU_VBAT_NOM_OFF = ["plpcdu-vbat-nom-off", "8"]
PL_PCDU_VBAT_RED_ON = ["plpcdu-vbat-red-on", "9"]
PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbt-red-off", "10"]
TCS_HEATER_IN_ON = ["tcs-heater-in-on", "11"]
TCS_HEATER_IN_OFF = ["tcs-heater-in-off", "12"]
SOLAR_ARRAY_DEPL_ON = ["sa-depl-on", "13"]
SOLAR_ARRAY_DEPL_OFF = ["sa-depl-off", "14"]
PL_CAMERA_ON = ["pl-cam-on", "15"]
PL_CAMERA_OFF = ["pl-cam-off", "16"]
# There is not really a point of the on command, the SW can not be commanded if the OBC is off.
# Actually, this command is dangerous and will probably be rejected by the OBC unless
# specifically configured to not reject it.
2022-03-14 11:04:40 +01:00
Q7S_OFF = "32"
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 14:45:24 +02:00
if op_code in Pdu2OpCodes.ACS_SIDE_B_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn ACS Side B on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_7.parameter_address,
PduConfigTable.out_en_7.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2021-09-07 15:45:05 +02:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.ACS_SIDE_B_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn ACS Side B off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_7.parameter_address,
PduConfigTable.out_en_7.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2021-09-07 15:45:05 +02:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.Q7S_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Turning off Q7S OBC")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_0.parameter_address,
PduConfigTable.out_en_0.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-01-18 14:03:56 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.SUS_REDUNDANT_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn SUS redundant on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_4.parameter_address,
PduConfigTable.out_en_4.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2022-01-18 14:03:56 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.SUS_REDUNDANT_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn SUS redundant off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_4.parameter_address,
PduConfigTable.out_en_4.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-01-18 14:03:56 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.RW_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn reaction wheels on")
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,
)
2021-09-15 18:48:28 +02:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.RW_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn reaction wheels 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
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_1.parameter_address,
PduConfigTable.out_en_1.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_1.parameter_address,
PduConfigTable.out_en_1.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_PCDU_VBAT_RED_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_6.parameter_address,
PduConfigTable.out_en_6.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_6.parameter_address,
PduConfigTable.out_en_6.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.TCS_HEATER_IN_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn TCS Heater Input on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.TCS_HEATER_IN_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn TCS Heater Input off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-03-16 18:44:28 +01:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn Solar Array Deployment On")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_5.parameter_address,
PduConfigTable.out_en_5.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn Solar Array Deployment Off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_5.parameter_address,
PduConfigTable.out_en_5.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_CAMERA_ON:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn payload camera on")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_8.parameter_address,
PduConfigTable.out_en_8.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2022-03-28 16:49:07 +02:00
)
2022-08-11 14:45:24 +02:00
if op_code in Pdu2OpCodes.PL_CAMERA_OFF:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Turn payload camera off")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_8.parameter_address,
PduConfigTable.out_en_8.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2022-03-28 16:49:07 +02:00
)
2022-04-08 14:46:01 +02:00
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
2022-07-04 15:22:53 +02:00
q.add_log_cmd(f"PDU2: {Info.REQUEST_CORE_HK_ONCE}")
2022-04-12 16:10:51 +02:00
hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_CORE)
2022-07-04 15:22:53 +02:00
q.add_pus_tc(generate_one_diag_command(sid=hk_sid))
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
2022-07-04 15:22:53 +02:00
q.add_log_cmd(f"PDU2: {Info.REQUEST_AUX_HK_ONCE}")
hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_AUX)
2022-07-04 15:22:53 +02:00
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
2022-04-04 18:46:52 +02:00
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Print Switches, Currents, Voltahes")
q.add_pus_tc(
generate_action_command(
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(
generate_action_command(
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))