# -*- 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 tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_3_fsfw_hk import ( generate_one_hk_command, generate_one_diag_command, make_sid, ) from gomspace.gomspace_common import * from gomspace.gomspace_pdu_definitions import * from config.object_ids import PDU_2_HANDLER_ID class Pdu2OpCodes(enum.Enum): ACS_SIDE_B_ON = "1" ACS_SIDE_B_OFF = "2" SUS_REDUNDANT_ON = "3" SUS_REDUNDANT_OFF = "4" RW_ON = "5" RW_OFF = "6" PL_PCDU_VBAT_NOM_ON = "7" PL_PCDU_VBAT_NOM_OFF = "8" PL_PCDU_VBAT_RED_ON = "9" PL_PCDU_VBAT_RED_OFF = "10" TCS_HEATER_IN_ON = "11" TCS_HEATER_IN_OFF = "12" SOLAR_ARRAY_DEPL_ON = "13" SOLAR_ARRAY_DEPL_OFF = "14" PL_CAMERA_ON = "15" PL_CAMERA_OFF = "16" # There is not really a point of the on command, the SW can not be commanded if the OBC is off Q7S_OFF = "32" 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 if op_code == Pdu2OpCodes.ACS_SIDE_B_ON.value: q.add_log_cmd("PDU2: Turn ACS Side B on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_7.parameter_address, PDUConfigTable.out_en_7.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.ACS_SIDE_B_OFF.value: q.add_log_cmd("PDU2: Turn ACS Side B off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_7.parameter_address, PDUConfigTable.out_en_7.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.Q7S_OFF.value: q.add_log_cmd("Turning off Q7S OBC") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_0.parameter_address, PDUConfigTable.out_en_0.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.SUS_REDUNDANT_ON.value: q.add_log_cmd("PDU2: Turn SUS redundant on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_4.parameter_address, PDUConfigTable.out_en_4.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.SUS_REDUNDANT_OFF.value: q.add_log_cmd("PDU2: Turn SUS redundant off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_4.parameter_address, PDUConfigTable.out_en_4.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.RW_ON.value: q.add_log_cmd("PDU2: Turn reaction wheels on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_2.parameter_address, PDUConfigTable.out_en_2.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.RW_OFF.value: q.add_log_cmd("PDU2: Turn reaction wheels 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 op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON.value: q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_1.parameter_address, PDUConfigTable.out_en_1.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF.value: q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_1.parameter_address, PDUConfigTable.out_en_1.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_ON.value: q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_6.parameter_address, PDUConfigTable.out_en_6.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF.value: q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_6.parameter_address, PDUConfigTable.out_en_6.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.TCS_HEATER_IN_ON.value: q.add_log_cmd("PDU2: Turn TCS Heater Input on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_3.parameter_address, PDUConfigTable.out_en_3.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.TCS_HEATER_IN_OFF.value: q.add_log_cmd("PDU2: Turn TCS Heater Input off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_3.parameter_address, PDUConfigTable.out_en_3.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON.value: q.add_log_cmd("PDU2: Turn Solar Array Deployment On") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_5.parameter_address, PDUConfigTable.out_en_5.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF.value: q.add_log_cmd("PDU2: Turn Solar Array Deployment Off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_5.parameter_address, PDUConfigTable.out_en_5.parameter_size, Channel.off, ) ) if op_code == Pdu2OpCodes.PL_CAMERA_ON.value: q.add_log_cmd("PDU2: Turn payload camera on") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_8.parameter_address, PDUConfigTable.out_en_8.parameter_size, Channel.on, ) ) if op_code == Pdu2OpCodes.PL_CAMERA_OFF.value: q.add_log_cmd("PDU2: Turn payload camera off") q.add_pus_tc( pack_set_param_command( objb, PDUConfigTable.out_en_8.parameter_address, PDUConfigTable.out_en_8.parameter_size, Channel.off, ) ) if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: q.add_log_cmd(f"PDU2: {Info.REQUEST_CORE_HK_ONCE}") hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_CORE) q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: 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) q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: 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 ) ) if op_code in GomspaceOpCodes.PRINT_LATCHUPS: q.add_log_cmd("PDU2: Print Latchups") q.add_pus_tc( generate_action_command( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS ) ) 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))