move power module

This commit is contained in:
2022-08-25 16:14:21 +02:00
parent 5c0def704f
commit df5d68315b
13 changed files with 15 additions and 25 deletions

View File

@ -1 +1 @@
from . import power

View File

@ -1,213 +0,0 @@
# -*- coding: utf-8 -*-
"""ACU commands
@author J. Meier, R. Mueller
@date 21.12.2020
"""
import struct
from config.definitions import CustomServiceList
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
generate_one_hk_command,
)
import gomspace.gomspace_common as gs
from gomspace.gomspace_common import GomspaceOpCodes
from gomspace.gomspace_common import GsInfo as GsInfo
from config.object_ids import ACU_HANDLER_ID
from pus_tc.devs.p60dock import P60DockConfigTable
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
from tmtccmd.util import ObjectIdU32
class ACUConfigTable:
mppt_mode = gs.TableEntry(bytearray([0x00, 0x00]), gs.TableEntry.uint8_size)
mppt_d_mode = gs.TableEntry(bytearray([0x00, 0x01]), gs.TableEntry.uint8_size)
vboost = gs.TableEntry(bytearray([0x00, 0x02]), gs.TableEntry.uint16_size)
vbat_max_hi = gs.TableEntry(bytearray([0x00, 0x10]), gs.TableEntry.uint16_size)
vbat_max_lo = gs.TableEntry(bytearray([0x00, 0x12]), gs.TableEntry.uint16_size)
ov_mode = gs.TableEntry(bytearray([0x00, 0x1A]), gs.TableEntry.uint8_size)
class ACUHkTable:
temperature1 = gs.TableEntry(bytearray([0x00, 0x1C]), gs.TableEntry.uint16_size)
temperature2 = gs.TableEntry(bytearray([0x00, 0x1D]), gs.TableEntry.uint16_size)
temperature3 = gs.TableEntry(bytearray([0x00, 0x1E]), gs.TableEntry.uint16_size)
# Ground WDT value (remaining seconds until reboot)
wdt_gnd_left = gs.TableEntry(bytearray([0x00, 0x74]), gs.TableEntry.uint32_size)
class OpCodes:
TEST = ["0", "test"]
class Info:
TEST = "ACU Test"
@tmtc_definitions_provider
def add_acu_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(
keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE,
info=GsInfo.REQUEST_CORE_HK_ONCE,
)
oce.add(
keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE,
info=GsInfo.REQUEST_AUX_HK_ONCE,
)
oce.add(
keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE,
info=GsInfo.REQUEST_AUX_HK_ONCE,
)
oce.add(
keys=GomspaceOpCodes.GET_PARAM,
info=GsInfo.GET_PARAMETER,
)
oce.add(
keys=GomspaceOpCodes.SET_PARAM,
info=GsInfo.SET_PARAMETER,
)
oce.add(keys=OpCodes.TEST, info=Info.TEST)
defs.add_service(
name=CustomServiceList.ACU.value,
info="ACU Device",
op_code_entry=oce,
)
def pack_acu_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
q.add_log_cmd("Handling ACU command")
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
q.add_log_cmd("ACU: Print channel stats")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=object_id.as_bytes,
action_id=gs.GomspaceDeviceActionIds.PRINT_SWITCH_V_I,
)
)
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
q.add_log_cmd(f"ACU: {GsInfo.REQUEST_CORE_HK_ONCE}")
hk_sid = make_sid(object_id=object_id.as_bytes, set_id=gs.SetIds.ACU_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"ACU: {GsInfo.REQUEST_AUX_HK_ONCE}")
hk_sid = make_sid(object_id=object_id.as_bytes, set_id=gs.SetIds.ACU_AUX)
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
if op_code in GomspaceOpCodes.GET_PARAM:
q.add_log_cmd(f"ACU: {GsInfo.GET_PARAMETER}")
gs.prompt_and_pack_get_param_command(q, object_id)
if op_code in GomspaceOpCodes.SET_PARAM:
q.add_log_cmd(f"ACU: {GsInfo.SET_PARAMETER}")
gs.prompt_and_pack_set_param_command(q, object_id)
pack_test_cmds(object_id=object_id, q=q)
class ACUTestProcedure:
"""
@brief Use this class to define the tests to perform for the ACU.
@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
read_temperature1 = False
read_temperature2 = False
read_temperature3 = False
read_mppt_mode = False
read_vboost = False
read_vbat_max_hi = False
read_vbat_max_lo = False
read_ov_mode = False
off = False
def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
if ACUTestProcedure.all or ACUTestProcedure.reboot:
q.add_log_cmd("ACU: Reboot")
q.add_pus_tc(gs.pack_reboot_command(object_id))
if ACUTestProcedure.all or ACUTestProcedure.read_gnd_wdt:
q.add_log_cmd("ACU: Reading ground watchdog timer value")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
ACUHkTable.wdt_gnd_left.parameter_address,
ACUHkTable.wdt_gnd_left.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.gnd_wdt_reset:
q.add_log_cmd("ACU: Testing ground watchdog reset")
q.add_pus_tc(gs.pack_gnd_wdt_reset_command(object_id))
if ACUTestProcedure.all or ACUTestProcedure.ping:
q.add_log_cmd("ACU: Ping Test")
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
q.add_pus_tc(gs.pack_ping_command(object_id, ping_data))
if ACUTestProcedure.all or ACUTestProcedure.read_temperature3:
q.add_log_cmd("ACU: Reading temperature 3")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
ACUHkTable.temperature3.parameter_address,
ACUHkTable.temperature3.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.read_vboost:
q.add_log_cmd("ACU: Reading vboost value")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vboost.parameter_address,
ACUConfigTable.vboost.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_hi:
q.add_log_cmd("ACU: Reading vbat_max_hi")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vbat_max_hi.parameter_address,
ACUConfigTable.vbat_max_hi.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_lo:
q.add_log_cmd("ACU: Reading vbat_max_lo")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vbat_max_lo.parameter_address,
ACUConfigTable.vbat_max_lo.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.read_ov_mode:
q.add_log_cmd("ACU: Reading ov_mode")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.ov_mode.parameter_address,
ACUConfigTable.ov_mode.parameter_size,
)
)
if ACUTestProcedure.all or ACUTestProcedure.off:
q.add_log_cmd("P60 Dock: Turning off ACU")
q.add_pus_tc(
gs.pack_set_param_command(
ACU_HANDLER_ID,
P60DockConfigTable.out_en_0.parameter_address,
P60DockConfigTable.out_en_0.parameter_size,
gs.Channel.off,
)
)

View File

@ -1,472 +0,0 @@
import enum
import struct
from config.object_ids import PDU_1_HANDLER_ID, PDU_2_HANDLER_ID
from gomspace.gomspace_common import (
pack_set_param_command,
Channel,
GomspaceOpCodes,
GsInfo,
SetIds,
GomspaceDeviceActionIds,
)
from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST
from pus_tm.defs import PrintWrapper
from tmtccmd.config import OpCodeEntry
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
generate_one_hk_command,
)
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class Pdu1ChIndex(enum.IntEnum):
TCS = 0
SYRLINKS = 1
STR = 2
MGT = 3
SUS_N = 4
SCEX = 5
PLOC = 6
ACS_A = 7
class Pdu1InfoBase:
TCS = "Switch TCS Board"
SYRLINKS = "Switch Syrlinks (COM)"
STR = "Switch Startracker"
MGT = "Switch Magnetorquer"
SUS_N = "Switch Sun Sensor Board Nominal"
SCEX = "Switch Solar Cell Experiment"
PLOC = "Switch Payload On-Board Computer"
ACS_A = "Switch ACS Board A-Side"
class Pdu2InfoBase:
PL_PCDU_BAT_NOM = "Switch PL PCDU Nominal Battery Channel"
RW = "Switch Reaction Wheel"
HEATER = "Switch Heater"
SUS_R = "Switch Sun Sensor Board Redundant"
SOLAR_ARRAY_DEPL = "Switch Solar Array Deployment"
PL_PCDU_BAT_RED = "Switch PL PCDU Redundant Battery Channel"
ACS_B = "Switch ACS Board B-Side"
PL_CAM = "Switch Payload Camera"
class PowerInfo:
INFO_CORE = "Core Information"
INFO_AUX = "Auxiliary Information"
INFO_ALL = "All Information"
class Pdu2ChIndex(enum.IntEnum):
PL_PCDU_BAT_NOM = 1
RW = 2
HEATER = 3
SUS_R = 4
SOLAR_ARRAY_DEPL = 5
PL_PCDU_BAT_RED = 6
ACS_B = 7
PL_CAM = 8
class PowerOpCodes:
# PDU 1
TCS_ON = ["tcs-on"]
TCS_OFF = ["tcs-off"]
SYRLINKS_ON = ["syrlinks-on"]
SYRLINKS_OFF = ["syrlinks-off"]
STAR_TRACKER_ON = ["str-on"]
STAR_TRACKER_OFF = ["str-off"]
MGT_ON = ["mgt-on"]
MGT_OFF = ["mgt-off"]
SUS_N_ON = ["sus-nom-on"]
SUS_N_OFF = ["sus-nom-off"]
SCEX_ON = ["scex-on"]
SCEX_OFF = ["scex-off"]
PLOC_ON = ["ploc-on"]
PLOC_OFF = ["ploc-off"]
ACS_A_ON = ["acs-a-on"]
ACS_A_OFF = ["acs-a-off"]
# PDU 2
PL_PCDU_VBAT_NOM_ON = ["plpcdu-vbat-nom-on"]
PL_PCDU_VBAT_NOM_OFF = ["plpcdu-vbat-nom-off"]
RW_ON = ["rw-on"]
RW_OFF = ["rw-off"]
HEATER_ON = ["heater-on"]
HEATER_OFF = ["heater-off"]
SUS_R_ON = ["sus-red-on"]
SUS_R_OFF = ["sus-red-off"]
SOLAR_ARRAY_DEPL_ON = ["sa-depl-on"]
SOLAR_ARRAY_DEPL_OFF = ["sa-depl-off"]
PL_PCDU_VBAT_RED_ON = ["plpcdu-vbat-red-on"]
PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbat-red-off"]
ACS_B_ON = ["acs-b-on"]
ACS_B_OFF = ["acs-b-off"]
PL_CAM_ON = ["cam-on"]
PL_CAM_OFF = ["cam-off"]
INFO_CORE = ["info"]
INFO_AUX = ["info-aux"]
INFO_ALL = ["info-all"]
def info_on_pdu1(base: str) -> str:
return "PDU1: " + base + " on"
def info_off_pdu1(base: str) -> str:
return "PDU1: " + base + " off"
def info_on_pdu2(base: str) -> str:
return "PDU2: " + base + " on"
def info_off_pdu2(base: str) -> str:
return "PDU2: " + base + " off"
def add_pdu1_common_defs(oce: OpCodeEntry):
oce.add(keys=PowerOpCodes.TCS_ON, info=info_on_pdu1(Pdu1InfoBase.TCS))
oce.add(keys=PowerOpCodes.TCS_OFF, info=info_off_pdu1(Pdu1InfoBase.TCS))
oce.add(keys=PowerOpCodes.STAR_TRACKER_ON, info=info_on_pdu1(Pdu1InfoBase.STR))
oce.add(keys=PowerOpCodes.STAR_TRACKER_OFF, info=info_off_pdu1(Pdu1InfoBase.STR))
oce.add(keys=PowerOpCodes.SUS_N_ON, info=info_on_pdu1(Pdu1InfoBase.SUS_N))
oce.add(keys=PowerOpCodes.SUS_N_OFF, info=info_off_pdu1(Pdu1InfoBase.SUS_N))
oce.add(keys=PowerOpCodes.ACS_A_ON, info=info_on_pdu1(Pdu1InfoBase.ACS_A))
oce.add(keys=PowerOpCodes.ACS_A_OFF, info=info_off_pdu1(Pdu1InfoBase.ACS_A))
oce.add(keys=PowerOpCodes.SYRLINKS_ON, info=info_on_pdu1(Pdu1InfoBase.SYRLINKS))
oce.add(keys=PowerOpCodes.SYRLINKS_OFF, info=info_off_pdu1(Pdu1InfoBase.SYRLINKS))
oce.add(keys=PowerOpCodes.MGT_ON, info=info_on_pdu1(Pdu1InfoBase.MGT))
oce.add(keys=PowerOpCodes.MGT_OFF, info=info_off_pdu1(Pdu1InfoBase.MGT))
oce.add(keys=PowerOpCodes.PLOC_ON, info=info_on_pdu1(Pdu1InfoBase.PLOC))
oce.add(keys=PowerOpCodes.PLOC_OFF, info=info_off_pdu1(Pdu1InfoBase.PLOC))
oce.add(keys=PowerOpCodes.SCEX_ON, info=info_on_pdu1(Pdu1InfoBase.SCEX))
oce.add(keys=PowerOpCodes.SCEX_OFF, info=info_off_pdu1(Pdu1InfoBase.SCEX))
def add_pdu2_common_defs(oce: OpCodeEntry):
oce.add(keys=PowerOpCodes.ACS_B_ON, info=info_on_pdu2(Pdu2InfoBase.ACS_B))
oce.add(keys=PowerOpCodes.ACS_B_OFF, info=info_off_pdu2(Pdu2InfoBase.ACS_B))
oce.add(keys=PowerOpCodes.SUS_R_ON, info=info_on_pdu2(Pdu2InfoBase.SUS_R))
oce.add(keys=PowerOpCodes.SUS_R_OFF, info=info_off_pdu2(Pdu2InfoBase.SUS_R))
oce.add(keys=PowerOpCodes.RW_ON, info=info_on_pdu2(Pdu2InfoBase.RW))
oce.add(keys=PowerOpCodes.RW_OFF, info=info_off_pdu2(Pdu2InfoBase.RW))
oce.add(
keys=PowerOpCodes.PL_PCDU_VBAT_NOM_ON,
info=info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM),
)
oce.add(
keys=PowerOpCodes.PL_PCDU_VBAT_NOM_OFF,
info=info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM),
)
oce.add(
keys=PowerOpCodes.PL_PCDU_VBAT_RED_ON,
info=info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED),
)
oce.add(
keys=PowerOpCodes.PL_PCDU_VBAT_RED_OFF,
info=info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED),
)
oce.add(keys=PowerOpCodes.HEATER_ON, info=info_on_pdu2(Pdu2InfoBase.HEATER))
oce.add(keys=PowerOpCodes.HEATER_OFF, info=info_off_pdu2(Pdu2InfoBase.HEATER))
oce.add(
keys=PowerOpCodes.SOLAR_ARRAY_DEPL_ON,
info=info_on_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL),
)
oce.add(
keys=PowerOpCodes.SOLAR_ARRAY_DEPL_OFF,
info=info_off_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL),
)
oce.add(keys=PowerOpCodes.PL_CAM_ON, info=info_on_pdu2(Pdu2InfoBase.PL_CAM))
oce.add(keys=PowerOpCodes.PL_CAM_OFF, info=info_off_pdu2(Pdu2InfoBase.PL_CAM))
def pdu1_cmds(q: DefaultPusQueueHelper, op_code: str):
if op_code in PowerOpCodes.TCS_ON:
tcs_on_cmd(q)
elif op_code in PowerOpCodes.TCS_OFF:
tcs_off_cmd(q)
elif op_code in PowerOpCodes.SYRLINKS_ON:
syrlinks_on_cmd(q)
elif op_code in PowerOpCodes.SYRLINKS_OFF:
syrlinks_off_cmd(q)
elif op_code in PowerOpCodes.STAR_TRACKER_ON:
startracker_on_cmd(q)
elif op_code in PowerOpCodes.STAR_TRACKER_OFF:
startracker_off_cmd(q)
elif op_code in PowerOpCodes.MGT_ON:
mgt_on_cmd(q)
elif op_code in PowerOpCodes.MGT_OFF:
mgt_off_cmd(q)
elif op_code in PowerOpCodes.SUS_N_ON:
sun_sensor_nominal_on_cmd(q)
elif op_code in PowerOpCodes.SUS_N_OFF:
sun_sensor_nominal_off_cmd(q)
elif op_code in PowerOpCodes.SCEX_ON:
solar_cell_experiment_on_cmd(q)
elif op_code in PowerOpCodes.SCEX_OFF:
solar_cell_experiment_off_cmd(q)
elif op_code in PowerOpCodes.PLOC_ON:
ploc_on_cmd(q)
elif op_code in PowerOpCodes.PLOC_OFF:
ploc_off_cmd(q)
elif op_code in PowerOpCodes.ACS_A_ON:
acs_board_a_on_cmd(q)
elif op_code in PowerOpCodes.ACS_A_OFF:
acs_board_a_off_cmd(q)
def pdu2_cmds(q: DefaultPusQueueHelper, op_code: str):
if op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_ON:
pl_pcdu_bat_nom_on_cmd(q)
elif op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_OFF:
pl_pcdu_bat_nom_off_cmd(q)
elif op_code in PowerOpCodes.RW_ON:
reaction_wheel_on_cmd(q)
elif op_code in PowerOpCodes.RW_OFF:
reaction_wheel_off_cmd(q)
elif op_code in PowerOpCodes.HEATER_ON:
heater_on_cmd(q)
elif op_code in PowerOpCodes.HEATER_OFF:
heater_off_cmd(q)
elif op_code in PowerOpCodes.SUS_R_ON:
sus_red_on_cmd(q)
elif op_code in PowerOpCodes.SUS_R_OFF:
sus_red_off_cmd(q)
elif op_code in PowerOpCodes.SOLAR_ARRAY_DEPL_ON:
solar_array_deployment_on_cmd(q)
elif op_code in PowerOpCodes.SOLAR_ARRAY_DEPL_OFF:
solar_array_deployment_off_cmd(q)
elif op_code in PowerOpCodes.PL_PCDU_VBAT_RED_ON:
pl_pcdu_bat_red_on_cmd(q)
elif op_code in PowerOpCodes.PL_PCDU_VBAT_RED_OFF:
pl_pcdu_bat_nom_off_cmd(q)
elif op_code in PowerOpCodes.ACS_B_ON:
acs_board_b_side_on_cmd(q)
elif op_code in PowerOpCodes.ACS_B_OFF:
acs_board_b_side_off_cmd(q)
elif op_code in PowerOpCodes.PL_CAM_ON:
payload_camera_on_cmd(q)
elif op_code in PowerOpCodes.PL_CAM_OFF:
payload_camera_off_cmd(q)
def pdu1_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
q.add_log_cmd(f"PDU1: {GsInfo.REQUEST_CORE_HK_ONCE}")
hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_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"PDU1: {GsInfo.REQUEST_AUX_HK_ONCE}")
hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_AUX)
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
def pdu2_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
q.add_log_cmd(f"PDU2: {GsInfo.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: {GsInfo.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))
def tcs_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS)
def tcs_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS)
def syrlinks_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS)
def syrlinks_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS)
def startracker_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR)
def startracker_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR)
def mgt_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT)
def mgt_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT)
def sun_sensor_nominal_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SUS_N, Pdu1ChIndex.SUS_N)
def sun_sensor_nominal_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SUS_N, Pdu1ChIndex.SUS_N)
def solar_cell_experiment_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX)
def solar_cell_experiment_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX)
def ploc_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC)
def ploc_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC)
def acs_board_a_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.ACS_A, Pdu1ChIndex.ACS_A)
def acs_board_a_off_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.ACS_A, Pdu1ChIndex.ACS_A)
def pl_pcdu_bat_nom_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_NOM, Pdu2ChIndex.PL_PCDU_BAT_NOM
)
def pl_pcdu_bat_nom_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_NOM, Pdu2ChIndex.PL_PCDU_BAT_NOM
)
def reaction_wheel_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.RW, Pdu2ChIndex.RW)
def reaction_wheel_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.RW, Pdu2ChIndex.RW)
def heater_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER)
def heater_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER)
def sus_red_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R)
def sus_red_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R)
def solar_array_deployment_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL
)
def solar_array_deployment_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL
)
def pl_pcdu_bat_red_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_RED, Pdu2ChIndex.PL_PCDU_BAT_RED
)
def pl_pcdu_bat_red_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_RED, Pdu2ChIndex.PL_PCDU_BAT_RED
)
def acs_board_b_side_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B)
def acs_board_b_side_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B)
def payload_camera_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM)
def payload_camera_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM)
def generic_on_cmd(
object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int
):
q.add_log_cmd(info_str + " on")
q.add_pus_tc(
pack_set_param_command(
object_id,
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
Channel.on,
)
)
def generic_off_cmd(
object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int
):
q.add_log_cmd(info_str + " off")
q.add_pus_tc(
pack_set_param_command(
object_id,
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
Channel.off,
)
)
def handle_get_param_data_reply(
action_id: int, pw: PrintWrapper, custom_data: bytearray
):
if action_id == GomspaceDeviceActionIds.PARAM_GET:
header_list = [
"Gomspace action ID",
"Table ID",
"Memory Address",
"Payload length",
"Payload",
]
fmt_str = "!BBHH"
(action, table_id, address, payload_length) = struct.unpack(
fmt_str, custom_data[:6]
)
content_list = [
action,
table_id,
hex(address),
payload_length,
"0x" + custom_data[6:].hex(),
]
pw.dlog(f"{header_list}")
pw.dlog(f"{content_list}")

View File

@ -1,289 +0,0 @@
# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_p60dock.py
@brief P60 Dock tests
@author J. Meier
@date 13.12.2020
"""
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from gomspace.gomspace_common import (
GsInfo,
GomspaceOpCodes,
TableEntry,
Channel,
pack_set_param_command,
TableIds,
pack_get_param_command,
pack_gnd_wdt_reset_command,
pack_ping_command,
GomspaceDeviceActionIds,
pack_reboot_command,
SetIds,
)
from config.object_ids import P60_DOCK_HANDLER
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
from tmtccmd.util import ObjectIdU32
class P60OpCodes:
STACK_3V3_ON = ["stack-3v3-on", "1"]
STACK_3V3_OFF = ["stack-3v3-off", "2"]
STACK_5V_ON = ["stack-5v-on", "3"]
STACK_5V_OFF = ["stack-5v-off", "4"]
TEST = ["test", "0"]
class P60Info:
PREFIX = "P60 Dock"
STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on"
STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off"
STACK_5V_ON = f"{PREFIX}: Turn Stack 5V on"
STACK_5V_OFF = f"{PREFIX}: Turn Stack 5V off"
class P60DockTestProcedure:
"""
@brief Use this class to define the tests to perform for the P60Dock.
@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_3_off = False # pdu2
read_temperature1 = False
read_channel_3_state = False # pdu2
read_cur_lu_lim_0 = False
channel_3_on = False # pdu2
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
class P60DockConfigTable:
out_en_0 = TableEntry(bytearray([0x00, 0x68]), TableEntry.uint8_size) # ACU VCC
out_en_1 = TableEntry(bytearray([0x00, 0x69]), TableEntry.uint8_size) # PDU1 VCC
out_en_2 = TableEntry(bytearray([0x00, 0x6A]), TableEntry.uint8_size) # unused
out_en_3 = TableEntry(bytearray([0x00, 0x6B]), TableEntry.uint8_size) # PDU2 VCC
out_en_4 = TableEntry(bytearray([0x00, 0x6C]), TableEntry.uint8_size) # ACU VBAT
out_en_5 = TableEntry(bytearray([0x00, 0x6D]), TableEntry.uint8_size) # unused
out_en_6 = TableEntry(bytearray([0x00, 0x6E]), TableEntry.uint8_size) # PDU1 VBAT
out_en_7 = TableEntry(bytearray([0x00, 0x6F]), TableEntry.uint8_size) # PDU2 VBAT
out_en_8 = TableEntry(bytearray([0x00, 0x70]), TableEntry.uint8_size) # Stack VBAT
out_en_9 = TableEntry(bytearray([0x00, 0x71]), TableEntry.uint8_size) # Stack 3V3
out_en_10 = TableEntry(bytearray([0x00, 0x72]), TableEntry.uint8_size) # Stack 5V
out_en_11 = TableEntry(
bytearray([0x00, 0x73]), TableEntry.uint8_size
) # GS 3V3 (unused)
out_en_12 = TableEntry(
bytearray([0x00, 0x74]), TableEntry.uint8_size
) # GS 5V (unused)
# When channel consumes more than cur_lu_lim, channel is turned of immediately
cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xF8]), TableEntry.uint16_size)
class P60DockHkTable:
temperature1 = TableEntry(bytearray([0x00, 0x44]), TableEntry.uint16_size)
temperature2 = TableEntry(bytearray([0x00, 0x46]), TableEntry.uint16_size)
# Ground WDT value (remaining seconds until reboot)
wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size)
def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
objb = object_id.as_bytes
if op_code in P60OpCodes.STACK_3V3_ON:
q.add_log_cmd(P60Info.STACK_3V3_ON)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.on,
)
)
if op_code in P60OpCodes.STACK_3V3_OFF:
q.add_log_cmd(P60Info.STACK_3V3_OFF)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.off,
)
)
if op_code in P60OpCodes.STACK_5V_ON:
q.add_log_cmd(P60Info.STACK_5V_ON)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.on,
)
)
if op_code in P60OpCodes.STACK_5V_OFF:
q.add_log_cmd(P60Info.STACK_5V_OFF)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.off,
)
)
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
q.add_log_cmd("P60 Dock: Requesting HK Core HK Once")
hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_CORE)
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
q.add_log_cmd("P60 Dock: Requesting HK Aux HK Once")
hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_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("P60 Dock: Print Switches, Voltages, Currents")
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("P60 Dock: Print Latchups")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.reboot:
q.add_log_cmd("P60 Dock: Reboot")
q.add_pus_tc(pack_reboot_command(object_id))
if P60DockTestProcedure.all or P60DockTestProcedure.read_gnd_wdt:
q.add_log_cmd("P60 Dock: Reading ground watchdog timer value")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.wdt_gnd_left.parameter_address,
P60DockHkTable.wdt_gnd_left.parameter_size,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.gnd_wdt_reset:
q.add_log_cmd("P60 Dock: Testing ground watchdog reset")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
if P60DockTestProcedure.all or P60DockTestProcedure.ping:
q.add_log_cmd("P60 Dock: Ping")
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 P60DockTestProcedure.all or P60DockTestProcedure.channel_3_off:
q.add_log_cmd("P60 Dock: Testing setting output channel 3 off")
parameter = 0 # set channel off
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.read_temperature1:
q.add_log_cmd("P60 Dock: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
q.add_log_cmd("P60 Dock: Testing Output Channel 3 state (PDU2)")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.read_cur_lu_lim_0:
q.add_log_cmd("P60 Dock: Reading current limit value of output channel 0")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.cur_lu_lim_0.parameter_address,
P60DockConfigTable.cur_lu_lim_0.parameter_size,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
q.add_log_cmd("P60 Dock: Testing setting output channel 3 on")
parameter = 1 # set channel on
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_table_id_test:
q.add_log_cmd("P60 Dock: Testing invalid table id handling")
table_id_invalid = 5
q.add_pus_tc(
pack_get_param_command(
objb,
table_id_invalid,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
)
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_address_test:
q.add_log_cmd("P60 Dock: Testing invalid address handling in get param command")
invalid_address = bytearray([0x01, 0xF4])
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
invalid_address,
P60DockHkTable.temperature1.parameter_size,
)
)
q.add_log_cmd("P60 Dock: Testing invalid address handling in set param command")
invalid_address = bytearray([0x01, 0xF4])
parameter_size = 2
parameter = 1
q.add_pus_tc(
pack_set_param_command(objb, invalid_address, parameter_size, parameter)
)
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_parameter_size_test:
q.add_log_cmd(
"P60 Dock: Testing handling of invalid parameter sizes in get-param command"
)
invalid_size = 5
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
invalid_size,
)
)
q.add_log_cmd(
"P60 Dock: Testing handling of invalid parameter size in set-param command"
)
parameter = 1
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
invalid_size,
parameter,
)
)

View File

@ -1,115 +0,0 @@
# -*- coding: utf-8 -*-
"""PDU1 is mounted on the X2 slot of the P60 dock
@author J. Meier
@date 17.12.2020
"""
import gomspace.gomspace_common as gs
from pus_tc.devs.common_power import pdu1_cmds, pdu1_req_hk_cmds
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
make_sid,
generate_one_diag_command,
)
from gomspace.gomspace_common import *
from gomspace.gomspace_pdu_definitions import *
from config.object_ids import PDU_1_HANDLER_ID
class PDU1TestProcedure:
"""
@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
ping = False
read_temperature = False
turn_channel_2_on = False # Star Tracker connected to this channel (5V)
turn_channel_2_off = False
turn_channel_3_on = False # MTQ connected to this channel (5V)
turn_channel_3_off = False
def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
q.add_log_cmd("Commanding PDU1")
objb = object_id.as_bytes
pdu1_cmds(q, op_code)
pdu1_req_hk_cmds(q, op_code)
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
q.add_log_cmd("PDU1: Print Switches, Voltages, Currents")
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("PDU1: 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"PDU1: {GsInfo.SET_PARAMETER}")
prompt_and_pack_set_param_command(q, object_id)
if op_code in GomspaceOpCodes.GET_PARAM:
q.add_log_cmd(f"PDU1: {GsInfo.GET_PARAMETER}")
gs.prompt_and_pack_get_param_command(q, object_id)
if PDU1TestProcedure.all or PDU1TestProcedure.ping:
q.add_log_cmd("PDU1: 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 PDU1TestProcedure.all or PDU1TestProcedure.read_temperature:
q.add_log_cmd("PDU1: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
PduHkTable.temperature.parameter_address,
PduHkTable.temperature.parameter_size,
)
)
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_on:
q.add_log_cmd("PDU1: Turn channel 2 on (Star Tracker)")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
Channel.on,
)
)
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_off:
q.add_log_cmd("PDU1: Turn channel 2 off (Star Tracker)")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
Channel.off,
)
)
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_on:
q.add_log_cmd("PDU1: Turn channel 3 on (MTQ)")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
Channel.on,
)
)
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_off:
q.add_log_cmd("PDU1: Turn channel 3 off (MTQ)")
q.add_pus_tc(
pack_set_param_command(
objb,
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
Channel.off,
)
)

View File

@ -1,138 +0,0 @@
# -*- 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))

View File

@ -1,133 +0,0 @@
from gomspace.gomspace_common import GsInfo
from pus_tc.devs.common_power import (
PowerOpCodes,
add_pdu1_common_defs,
add_pdu2_common_defs,
PowerInfo,
pdu1_cmds,
pdu2_cmds,
pdu1_req_hk_cmds,
pdu2_req_hk_cmds,
)
from config.definitions import CustomServiceList
from tmtccmd import get_console_logger
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, P60Info
from pus_tc.devs.acu import add_acu_cmds
from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
LOGGER = get_console_logger()
def pack_power_commands(q: DefaultPusQueueHelper, op_code: str):
pdu1_cmds(q, op_code)
pdu2_cmds(q, op_code)
if op_code in PowerOpCodes.INFO_CORE:
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
q.add_wait_seconds(3.0)
elif op_code in PowerOpCodes.INFO_AUX:
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
q.add_wait_seconds(3.0)
elif op_code in PowerOpCodes.INFO_ALL:
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
q.add_wait_seconds(3.0)
if q.empty():
LOGGER.info(f"Queue is empty, no stack for op code {op_code}")
@tmtc_definitions_provider
def add_p60_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(keys=P60OpCodes.STACK_3V3_ON, info=P60Info.STACK_3V3_ON)
oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF)
oce.add(keys=P60OpCodes.STACK_5V_ON, info=P60Info.STACK_5V_ON)
oce.add(keys=P60OpCodes.STACK_5V_OFF, info=P60Info.STACK_5V_OFF)
add_gomspace_cmds(oce)
oce.add(keys=P60OpCodes.TEST, info="P60 Tests")
defs.add_service(
name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce
)
@tmtc_definitions_provider
def add_power_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
add_pdu1_common_defs(oce)
add_pdu2_common_defs(oce)
oce.add(keys=PowerOpCodes.INFO_ALL, info=PowerInfo.INFO_ALL)
oce.add(keys=PowerOpCodes.INFO_CORE, info=PowerInfo.INFO_CORE)
oce.add(keys=PowerOpCodes.INFO_AUX, info=PowerInfo.INFO_AUX)
defs.add_service(
name=CustomServiceList.POWER.value,
info="Power Subsystem",
op_code_entry=oce,
)
@tmtc_definitions_provider
def add_pdu1_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
add_pdu1_common_defs(oce)
add_gomspace_cmds(oce)
oce.add(keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE)
oce.add(keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE)
oce.add(
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
info="PDU1: Print Switches, Voltages, Currents",
)
oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER)
defs.add_service(
name=CustomServiceList.PDU1.value,
info="PDU1 Device",
op_code_entry=oce,
)
@tmtc_definitions_provider
def add_pdu2_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
add_pdu2_common_defs(oce)
add_gomspace_cmds(oce)
oce.add(
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
info="PDU2: Print Switches, Voltages, Currents",
)
oce.add(
keys=GomspaceOpCodes.PRINT_LATCHUPS,
info="PDU2: Print Latchups",
)
defs.add_service(
name="pdu2",
info="PDU2 Device",
op_code_entry=oce,
)
def add_gomspace_cmds(oce: OpCodeEntry):
oce.add(
keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE,
info=GsInfo.REQUEST_CORE_HK_ONCE,
)
oce.add(
keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE,
info=GsInfo.REQUEST_AUX_HK_ONCE,
)
oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER)
oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info=GsInfo.PRINT_LATCHUPS)
oce.add(keys=GomspaceOpCodes.SET_PARAM, info=GsInfo.SET_PARAMETER)
def add_pcdu_cmds(defs: TmtcDefinitionWrapper):
add_p60_cmds(defs)
add_pdu1_cmds(defs)
add_pdu2_cmds(defs)
add_acu_cmds(defs)