Merge remote-tracking branch 'origin/main' into mueller_new_switcher_hk
This commit is contained in:
@ -4,12 +4,13 @@ from typing import List
|
||||
from eive_tmtc.gomspace.gomspace_common import (
|
||||
pack_set_u8_param_command,
|
||||
Channel,
|
||||
GomspaceDeviceActionIds,
|
||||
GomspaceDeviceActionId,
|
||||
prompt_and_pack_set_integer_param_command,
|
||||
prompt_and_pack_get_param_command,
|
||||
pack_request_config_command,
|
||||
pack_gnd_wdt_reset_command,
|
||||
ParamTypes,
|
||||
pack_reboot_command,
|
||||
)
|
||||
from eive_tmtc.gomspace.gomspace_pdu_definitions import OUT_ENABLE_LIST
|
||||
from spacepackets.ecss import PusTelecommand
|
||||
@ -22,17 +23,18 @@ from tmtccmd.tc.pus_3_fsfw_hk import (
|
||||
enable_periodic_hk_command_with_interval,
|
||||
disable_periodic_hk_command,
|
||||
)
|
||||
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
|
||||
from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
|
||||
from tmtccmd.util import ObjectIdU32, ObjectIdBase
|
||||
|
||||
|
||||
class GomspaceOpCodes:
|
||||
class GomspaceOpCode:
|
||||
GET_PARAM = ["get_param"]
|
||||
SET_INTEGER_PARAM = ["set_int_param"]
|
||||
SAVE_TABLE = ["save_table"]
|
||||
RESET_GND_WATCHDOG = ["reset_gnd_wdt"]
|
||||
SAVE_TABLE_DEFAULT = ["save_table_default"]
|
||||
LOAD_TABLE = ["load_table"]
|
||||
REBOOT = ["reboot"]
|
||||
REQUEST_CONFIG_TABLE = ["cfg_table"]
|
||||
|
||||
|
||||
@ -44,6 +46,7 @@ class GsInfo:
|
||||
SAVE_TABLE = "Save table non-volatile (file)"
|
||||
SAVE_TABLE_DEFAULT = "Save table non-volatile (default)"
|
||||
LOAD_TABLE = "Load Table"
|
||||
REBOOT = "Reboot PCDU module"
|
||||
|
||||
|
||||
class PowerInfo:
|
||||
@ -51,6 +54,7 @@ class PowerInfo:
|
||||
INFO_AUX = "Auxiliary Information"
|
||||
SWITCHER_HK = "Switcher State Information"
|
||||
INFO_ALL = "All Information"
|
||||
REQUEST_SWITCHER_SET = "Request Switcher Information"
|
||||
ENABLE_INFO_HK = "Enable Core Info HK"
|
||||
DISABLE_INFO_HK = "Disable Core Info HK"
|
||||
RESET_ALL_GND_WDTS = "Reset all Ground Watchdogs"
|
||||
@ -97,6 +101,7 @@ class PowerOpCodes:
|
||||
PL_CAM_ON = ["cam_on"]
|
||||
PL_CAM_OFF = ["cam_off"]
|
||||
|
||||
REBOOT = ["reboot"]
|
||||
INFO_CORE = ["info"]
|
||||
SWITCHER_HK = ["switcher_states"]
|
||||
ENABLE_INFO_HK = ["info_hk_on"]
|
||||
@ -111,7 +116,7 @@ class PowerOpCodes:
|
||||
PRINT_LATCHUPS = ["print_latchups"]
|
||||
|
||||
|
||||
class SetIds:
|
||||
class SetId:
|
||||
CORE = 1
|
||||
AUX = 2
|
||||
CONFIG = 3
|
||||
@ -125,13 +130,13 @@ def pack_common_power_cmds(
|
||||
interval = float(input("Specify HK interval in floating point seconds: "))
|
||||
q.add_log_cmd(f"{prefix}: {PowerInfo.ENABLE_INFO_HK} with interval {interval}")
|
||||
cmds = enable_periodic_hk_command_with_interval(
|
||||
True, make_sid(objb, SetIds.CORE), interval
|
||||
True, make_sid(objb, SetId.CORE), interval
|
||||
)
|
||||
for cmd in cmds:
|
||||
q.add_pus_tc(cmd)
|
||||
if op_code in PowerOpCodes.DISABLE_INFO_HK:
|
||||
q.add_log_cmd(f"{prefix}: {PowerInfo.DISABLE_INFO_HK}")
|
||||
q.add_pus_tc(disable_periodic_hk_command(True, make_sid(objb, SetIds.CORE)))
|
||||
q.add_pus_tc(disable_periodic_hk_command(True, make_sid(objb, SetId.CORE)))
|
||||
|
||||
|
||||
def pack_common_gomspace_cmds(
|
||||
@ -141,31 +146,34 @@ def pack_common_gomspace_cmds(
|
||||
if op_code in PowerOpCodes.PRINT_SWITCH_V_I:
|
||||
q.add_log_cmd(f"{prefix}: {PowerInfo.PRINT_SWITCH_V_I}")
|
||||
q.add_pus_tc(
|
||||
make_fsfw_action_cmd(
|
||||
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
|
||||
create_action_cmd(
|
||||
object_id=objb, action_id=GomspaceDeviceActionId.PRINT_SWITCH_V_I
|
||||
)
|
||||
)
|
||||
if op_code in PowerOpCodes.REBOOT:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.REBOOT}")
|
||||
q.add_pus_tc(pack_reboot_command(object_id))
|
||||
if op_code in PowerOpCodes.PRINT_LATCHUPS:
|
||||
q.add_log_cmd(f"{prefix}: {PowerInfo.PRINT_LATCHUPS}")
|
||||
q.add_pus_tc(
|
||||
make_fsfw_action_cmd(
|
||||
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
|
||||
create_action_cmd(
|
||||
object_id=objb, action_id=GomspaceDeviceActionId.PRINT_LATCHUPS
|
||||
)
|
||||
)
|
||||
if op_code in GomspaceOpCodes.SET_INTEGER_PARAM:
|
||||
if op_code in GomspaceOpCode.SET_INTEGER_PARAM:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.SET_PARAMETER}")
|
||||
print("Please specify the parameter type from index")
|
||||
for idx, v in enumerate(ParamTypes):
|
||||
print(f"{idx}: {v.name}")
|
||||
ptype = int(input("Index: "))
|
||||
prompt_and_pack_set_integer_param_command(q, object_id, ParamTypes(ptype))
|
||||
if op_code in GomspaceOpCodes.GET_PARAM:
|
||||
if op_code in GomspaceOpCode.GET_PARAM:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.GET_PARAMETER}")
|
||||
prompt_and_pack_get_param_command(q, object_id)
|
||||
if op_code in GomspaceOpCodes.REQUEST_CONFIG_TABLE:
|
||||
if op_code in GomspaceOpCode.REQUEST_CONFIG_TABLE:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_CONFIG_TABLE}")
|
||||
q.add_pus_tc(pack_request_config_command(object_id.as_bytes))
|
||||
if op_code in GomspaceOpCodes.SAVE_TABLE:
|
||||
if op_code in GomspaceOpCode.SAVE_TABLE:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.SAVE_TABLE}")
|
||||
source_table = int(
|
||||
input(
|
||||
@ -182,13 +190,13 @@ def pack_common_gomspace_cmds(
|
||||
))
|
||||
"""
|
||||
q.add_pus_tc(
|
||||
make_fsfw_action_cmd(
|
||||
create_action_cmd(
|
||||
object_id=object_id.as_bytes,
|
||||
action_id=GomspaceDeviceActionIds.SAVE_TABLE,
|
||||
action_id=GomspaceDeviceActionId.SAVE_TABLE,
|
||||
user_data=bytes([source_table]),
|
||||
)
|
||||
)
|
||||
if op_code in GomspaceOpCodes.SAVE_TABLE_DEFAULT:
|
||||
if op_code in GomspaceOpCode.SAVE_TABLE_DEFAULT:
|
||||
source_table = int(
|
||||
input(
|
||||
"Source table [0: Board Config, 1: Module Config, 2: Calibration Parameter]: "
|
||||
@ -197,13 +205,13 @@ def pack_common_gomspace_cmds(
|
||||
if source_table not in [0, 1, 2]:
|
||||
raise ValueError("Invalid source table index")
|
||||
q.add_pus_tc(
|
||||
make_fsfw_action_cmd(
|
||||
create_action_cmd(
|
||||
object_id=object_id.as_bytes,
|
||||
action_id=GomspaceDeviceActionIds.SAVE_TABLE_DEFAULT,
|
||||
action_id=GomspaceDeviceActionId.SAVE_TABLE_DEFAULT,
|
||||
user_data=bytes([source_table]),
|
||||
)
|
||||
)
|
||||
if op_code in GomspaceOpCodes.LOAD_TABLE:
|
||||
if op_code in GomspaceOpCode.LOAD_TABLE:
|
||||
target_table = int(
|
||||
input(
|
||||
"Target table ID [0: Board Config, 1: Module Config, 2: Calibration Parameter, "
|
||||
@ -225,13 +233,13 @@ def pack_common_gomspace_cmds(
|
||||
# Will be ignored
|
||||
source_table = 4
|
||||
q.add_pus_tc(
|
||||
make_fsfw_action_cmd(
|
||||
create_action_cmd(
|
||||
object_id=object_id.as_bytes,
|
||||
action_id=GomspaceDeviceActionIds.LOAD_TABLE,
|
||||
action_id=GomspaceDeviceActionId.LOAD_TABLE,
|
||||
user_data=bytes([source_table, target_table]),
|
||||
)
|
||||
)
|
||||
if op_code in GomspaceOpCodes.RESET_GND_WATCHDOG:
|
||||
if op_code in GomspaceOpCode.RESET_GND_WATCHDOG:
|
||||
q.add_log_cmd(f"{prefix}: {GsInfo.RESET_GND_WATCHDOG}")
|
||||
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
|
||||
|
||||
@ -268,12 +276,14 @@ 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_u8_param_command(
|
||||
object_id,
|
||||
OUT_ENABLE_LIST[out_idx].parameter_address,
|
||||
Channel.on,
|
||||
)
|
||||
q.add_pus_tc(create_generic_on_cmd(object_id, out_idx))
|
||||
|
||||
|
||||
def create_generic_on_cmd(object_id: bytes, out_idx: int):
|
||||
return pack_set_u8_param_command(
|
||||
object_id,
|
||||
OUT_ENABLE_LIST[out_idx].parameter_address,
|
||||
Channel.on,
|
||||
)
|
||||
|
||||
|
||||
@ -281,12 +291,14 @@ 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_u8_param_command(
|
||||
object_id,
|
||||
OUT_ENABLE_LIST[out_idx].parameter_address,
|
||||
Channel.off,
|
||||
)
|
||||
q.add_pus_tc(create_generic_off_cmd(object_id, out_idx))
|
||||
|
||||
|
||||
def create_generic_off_cmd(object_id: bytes, out_idx: int):
|
||||
return pack_set_u8_param_command(
|
||||
object_id,
|
||||
OUT_ENABLE_LIST[out_idx].parameter_address,
|
||||
Channel.off,
|
||||
)
|
||||
|
||||
|
||||
@ -307,13 +319,14 @@ def add_gomspace_cmd_defs(oce: OpCodeEntry):
|
||||
info=PowerInfo.REQUEST_AUX_HK_ONCE,
|
||||
)
|
||||
oce.add(keys=PowerOpCodes.PRINT_LATCHUPS, info=PowerInfo.PRINT_LATCHUPS)
|
||||
oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER)
|
||||
oce.add(keys=GomspaceOpCodes.SET_INTEGER_PARAM, info=GsInfo.SET_PARAMETER)
|
||||
oce.add(keys=GomspaceOpCodes.REQUEST_CONFIG_TABLE, info=GsInfo.REQUEST_CONFIG_TABLE)
|
||||
oce.add(keys=GomspaceOpCodes.SAVE_TABLE, info=GsInfo.SAVE_TABLE)
|
||||
oce.add(keys=GomspaceOpCodes.SAVE_TABLE_DEFAULT, info=GsInfo.SAVE_TABLE_DEFAULT)
|
||||
oce.add(keys=GomspaceOpCodes.LOAD_TABLE, info=GsInfo.LOAD_TABLE)
|
||||
oce.add(keys=GomspaceOpCodes.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG)
|
||||
oce.add(keys=GomspaceOpCode.GET_PARAM, info=GsInfo.GET_PARAMETER)
|
||||
oce.add(keys=GomspaceOpCode.REBOOT, info=GsInfo.REBOOT)
|
||||
oce.add(keys=GomspaceOpCode.SET_INTEGER_PARAM, info=GsInfo.SET_PARAMETER)
|
||||
oce.add(keys=GomspaceOpCode.REQUEST_CONFIG_TABLE, info=GsInfo.REQUEST_CONFIG_TABLE)
|
||||
oce.add(keys=GomspaceOpCode.SAVE_TABLE, info=GsInfo.SAVE_TABLE)
|
||||
oce.add(keys=GomspaceOpCode.SAVE_TABLE_DEFAULT, info=GsInfo.SAVE_TABLE_DEFAULT)
|
||||
oce.add(keys=GomspaceOpCode.LOAD_TABLE, info=GsInfo.LOAD_TABLE)
|
||||
oce.add(keys=GomspaceOpCode.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG)
|
||||
|
||||
|
||||
OBC_ENDIANNESS = "<"
|
||||
|
Reference in New Issue
Block a user