more power commands

This commit is contained in:
Robin Müller 2022-08-31 21:15:31 +02:00
parent 05dd173860
commit f5a83db43d
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
12 changed files with 137 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="P60 Dock Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Core">
<configuration default="false" name="P60 Dock Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Power">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PDU1 Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Core">
<configuration default="false" name="PDU1 Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Power">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PDU2 Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Core">
<configuration default="false" name="PDU2 Commanding" type="PythonConfigurationType" factoryName="Python" folderName="Power">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reset GND WDTs" type="PythonConfigurationType" factoryName="Python" folderName="Power">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcc.py" />
<option name="PARAMETERS" value="-s power -o reset_gnd_wdts -d 0.1" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Set Current Time" type="PythonConfigurationType" factoryName="Python" folderName="Core">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcc.py" />
<option name="PARAMETERS" value="-s time -o set-curr-time" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -13,7 +13,7 @@ from typing import Union
from spacepackets.ecss import PusTelecommand
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
from tmtccmd.util import ObjectIdU32
from tmtccmd.util import ObjectIdU32, ObjectIdBase
class GomspaceDeviceActionIds(enum.IntEnum):
@ -24,6 +24,8 @@ class GomspaceDeviceActionIds(enum.IntEnum):
WDT_RESET = 9
REQUEST_HK_TABLE = 16
REQUEST_CONFIG_TABLE = 17
SAVE_TABLE = 18
SAVE_TABLE_DEFAULT = 19
PRINT_SWITCH_V_I = 32
PRINT_LATCHUPS = 33
@ -36,6 +38,9 @@ class GomspaceOpCodes:
PRINT_LATCHUPS = ["print_latchups"]
GET_PARAM = ["get_param"]
SET_PARAM = ["set_param"]
SAVE_TABLE = ["save_table"]
RESET_GND_WATCHDOG = ["reset_gnd_wdt"]
SAVE_TABLE_DEFAULT = ["save_table_default"]
REQUEST_CONFIG_TABLE = ["cfg_table"]
@ -47,6 +52,9 @@ class GsInfo:
GET_PARAMETER = "Get parameter"
SET_PARAMETER = "Set parameter"
REQUEST_CONFIG_TABLE = "Request Config Table"
RESET_GND_WATCHDOG = "Reset GND watchdog"
SAVE_TABLE = "Save table non-volatile (file)"
SAVE_TABLE_DEFAULT = "Save table non-volatile (default)"
class SetIds:
@ -184,7 +192,7 @@ def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand
)
def pack_gnd_wdt_reset_command(object_id: ObjectIdU32) -> PusTelecommand:
def pack_gnd_wdt_reset_command(object_id: ObjectIdBase) -> PusTelecommand:
""" " Function to generate the command to reset the watchdog of a gomspace device.
@param object_id Object Id of the gomspace device handler.
"""

View File

@ -6,7 +6,7 @@
from config.definitions import CustomServiceList
from tmtc.power.common_power import (
add_gomspace_cmds,
pack_gomspace_cmds,
add_gomspace_cmd_defs,
req_hk_cmds,
)
@ -68,7 +68,7 @@ def add_acu_cmds(defs: TmtcDefinitionWrapper):
def pack_acu_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
q.add_log_cmd("Handling ACU command")
add_gomspace_cmds("ACU", object_id, q, op_code)
pack_gomspace_cmds("ACU", object_id, q, op_code)
acu_req_hk_cmds(q, op_code)
pack_test_cmds(object_id=object_id, q=q)

View File

@ -7,6 +7,7 @@ from gomspace.gomspace_common import (
prompt_and_pack_set_param_command,
prompt_and_pack_get_param_command,
pack_request_config_command,
pack_gnd_wdt_reset_command,
)
from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST
from tmtccmd.config import OpCodeEntry
@ -17,13 +18,14 @@ from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
)
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
from tmtccmd.util import ObjectIdU32
from tmtccmd.util import ObjectIdU32, ObjectIdBase
class PowerInfo:
INFO_CORE = "Core Information"
INFO_AUX = "Auxiliary Information"
INFO_ALL = "All Information"
RESET_ALL_GND_WDTS = "Reset all Ground Watchdogs"
class PowerOpCodes:
@ -66,9 +68,10 @@ class PowerOpCodes:
INFO_CORE = ["info"]
INFO_AUX = ["info_aux"]
INFO_ALL = ["info_all"]
RESET_ALL_GND_WDTS = ["reset_gnd_wdts"]
def add_gomspace_cmds(
def pack_gomspace_cmds(
prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
objb = object_id.as_bytes
@ -95,6 +98,51 @@ def add_gomspace_cmds(
if op_code in GomspaceOpCodes.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:
q.add_log_cmd(f"{prefix}: {GsInfo.SAVE_TABLE}")
source_table = int(
input(
"Source table [0: Board Config, 1: Module Config, "
"2: Calibration Parameter, 4: TM Data]: "
)
)
# Not used for now
"""
target_table = int(input(
"Target table. [Default: Source table]: "
))
"""
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=object_id.as_bytes,
action_id=GomspaceDeviceActionIds.SAVE_TABLE,
user_data=bytes([source_table]),
)
)
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]: "
)
)
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=object_id.as_bytes,
action_id=GomspaceDeviceActionIds.SAVE_TABLE_DEFAULT,
user_data=bytes([source_table]),
)
)
if op_code in GomspaceOpCodes.RESET_GND_WATCHDOG:
q.add_log_cmd(f"{prefix}: {GsInfo.RESET_GND_WATCHDOG}")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
def pack_reset_gnd_wdt_cmd(
q: DefaultPusQueueHelper, prefix: str, object_id: ObjectIdBase
):
q.add_log_cmd(f"{prefix}: {GsInfo.RESET_GND_WATCHDOG}")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
def req_hk_cmds(
@ -155,3 +203,6 @@ def add_gomspace_cmd_defs(oce: OpCodeEntry):
oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info=GsInfo.PRINT_LATCHUPS)
oce.add(keys=GomspaceOpCodes.SET_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.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG)

View File

@ -5,7 +5,7 @@
@author J. Meier
@date 13.12.2020
"""
from tmtc.power.common_power import add_gomspace_cmds, req_hk_cmds
from tmtc.power.common_power import pack_gomspace_cmds, req_hk_cmds
from tmtccmd.tc import DefaultPusQueueHelper
from gomspace.gomspace_common import (
TableEntry,
@ -95,7 +95,7 @@ class P60DockHkTable:
def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
objb = object_id.as_bytes
add_gomspace_cmds("P60 Dock", object_id, q, op_code)
pack_gomspace_cmds("P60 Dock", object_id, q, op_code)
p60_dock_req_hk_cmds(q, op_code)
if op_code in P60OpCodes.STACK_3V3_ON:
q.add_log_cmd(P60Info.STACK_3V3_ON)

View File

@ -5,7 +5,7 @@
"""
from config.object_ids import PDU_1_HANDLER_ID
from tmtc.power.common_power import (
add_gomspace_cmds,
pack_gomspace_cmds,
req_hk_cmds,
PowerOpCodes,
generic_on_cmd,
@ -61,7 +61,7 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
objb = object_id.as_bytes
pdu1_cmds(q, op_code)
pdu1_req_hk_cmds(q, op_code)
add_gomspace_cmds("PDU1", object_id, q, op_code)
pack_gomspace_cmds("PDU1", object_id, q, op_code)
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])

View File

@ -8,7 +8,7 @@
"""
from config.object_ids import PDU_2_HANDLER_ID
from tmtc.power.common_power import (
add_gomspace_cmds,
pack_gomspace_cmds,
req_hk_cmds,
PowerOpCodes,
generic_on_cmd,
@ -73,7 +73,7 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
objb = object_id.as_bytes
pdu2_cmds(q, op_code)
pdu2_req_hk_cmds(q, op_code)
add_gomspace_cmds("PDU2", object_id, q, op_code)
pack_gomspace_cmds("PDU2", object_id, q, op_code)
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
q.add_log_cmd("PDU2: Reboot")
q.add_pus_tc(pack_reboot_command(object_id))

View File

@ -3,8 +3,16 @@ from tmtc.power.common_power import (
PowerOpCodes,
PowerInfo,
add_gomspace_cmd_defs,
pack_reset_gnd_wdt_cmd,
)
from config.definitions import CustomServiceList
from config.object_ids import (
P60_DOCK_HANDLER,
ACU_HANDLER_ID,
PDU_1_HANDLER_ID,
PDU_2_HANDLER_ID,
get_object_ids,
)
from tmtc.power.pdu1 import pdu1_req_hk_cmds, pdu1_cmds, add_pdu1_common_defs
from tmtc.power.pdu2 import pdu2_req_hk_cmds, add_pdu2_common_defs, pdu2_cmds
from tmtccmd import get_console_logger
@ -44,6 +52,12 @@ def pack_power_commands(q: DefaultPusQueueHelper, op_code: str):
acu_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
acu_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
q.add_wait_seconds(8.0)
elif op_code in PowerOpCodes.RESET_ALL_GND_WDTS:
oids = get_object_ids()
pack_reset_gnd_wdt_cmd(q, "P60 Dock", oids[P60_DOCK_HANDLER])
pack_reset_gnd_wdt_cmd(q, "ACU", oids[ACU_HANDLER_ID])
pack_reset_gnd_wdt_cmd(q, "PDU1", oids[PDU_1_HANDLER_ID])
pack_reset_gnd_wdt_cmd(q, "PDU2", oids[PDU_2_HANDLER_ID])
if q.empty():
LOGGER.info(f"Queue is empty, no stack for op code {op_code}")
@ -70,6 +84,7 @@ def add_power_cmd_defs(defs: TmtcDefinitionWrapper):
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)
oce.add(keys=PowerOpCodes.RESET_ALL_GND_WDTS, info=PowerInfo.RESET_ALL_GND_WDTS)
defs.add_service(
name=CustomServiceList.POWER.value,
info="Power Subsystem",