update gomspace commands

This commit is contained in:
2022-09-01 16:58:31 +02:00
parent abecbe4401
commit e162e5c51b
16 changed files with 382 additions and 215 deletions

View File

@ -1,15 +1,17 @@
from gomspace.gomspace_common import (
pack_set_param_command,
pack_set_u8_param_command,
Channel,
GomspaceOpCodes,
GsInfo,
GomspaceDeviceActionIds,
prompt_and_pack_set_param_command,
prompt_and_pack_set_integer_param_command,
prompt_and_pack_get_param_command,
pack_request_config_command,
pack_gnd_wdt_reset_command,
ParamTypes,
)
from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST
from gomspace.gomspace_pdu_definitions import OUT_ENABLE_LIST
from spacepackets.ecss import PusTelecommand
from tmtccmd.config import OpCodeEntry
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
@ -30,40 +32,40 @@ class PowerInfo:
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"]
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"]
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"]
@ -89,9 +91,13 @@ def pack_gomspace_cmds(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
)
if op_code in GomspaceOpCodes.SET_PARAM:
if op_code in GomspaceOpCodes.SET_INTEGER_PARAM:
q.add_log_cmd(f"{prefix}: {GsInfo.SET_PARAMETER}")
prompt_and_pack_set_param_command(q, object_id)
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:
q.add_log_cmd(f"{prefix}: {GsInfo.GET_PARAMETER}")
prompt_and_pack_get_param_command(q, object_id)
@ -106,6 +112,8 @@ def pack_gomspace_cmds(
"2: Calibration Parameter, 4: TM Data]: "
)
)
if source_table not in [0, 1, 2, 4]:
raise ValueError("Invalid source table index")
# Not used for now
"""
target_table = int(input(
@ -122,10 +130,11 @@ def pack_gomspace_cmds(
if op_code in GomspaceOpCodes.SAVE_TABLE_DEFAULT:
source_table = int(
input(
"Source table [0: Board Config, 1: Module Config, "
"2: Calibration Parameter, 4: TM Data]: "
"Source table [0: Board Config, 1: Module Config, 2: Calibration Parameter]: "
)
)
if source_table not in [0, 1, 2]:
raise ValueError("Invalid source table index")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=object_id.as_bytes,
@ -162,15 +171,18 @@ def req_hk_cmds(
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
def pack_pdu_disable_safe_off_cmd() -> PusTelecommand:
pass
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(
pack_set_u8_param_command(
object_id,
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
OUT_ENABLE_LIST[out_idx].parameter_address,
Channel.on,
)
)
@ -181,10 +193,9 @@ def generic_off_cmd(
):
q.add_log_cmd(info_str + " off")
q.add_pus_tc(
pack_set_param_command(
pack_set_u8_param_command(
object_id,
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
OUT_ENABLE_LIST[out_idx].parameter_address,
Channel.off,
)
)
@ -201,7 +212,7 @@ def add_gomspace_cmd_defs(oce: OpCodeEntry):
)
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)
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)