Merge remote-tracking branch 'origin/main' into irini

This commit is contained in:
Irini Kosmidou 2022-09-27 16:49:37 +02:00
commit 135afdff3b
21 changed files with 574 additions and 228 deletions

24
.run/Info All.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Info All" 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 info_all" />
<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

@ -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

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PDU1 Aux Info" 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 info-aux -d 0.2" />
<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

@ -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" />
@ -13,7 +13,7 @@
<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 pdu1 -d 6" />
<option name="PARAMETERS" value="-s pdu1 -l" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />

24
.run/PDU1 Info.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PDU1 Info" 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 info -d 0.2" />
<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

@ -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" />
@ -13,7 +13,7 @@
<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 pdu2 -l -d 6" />
<option name="PARAMETERS" value="-s pdu2 -l" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Power Info All" 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 info_all -d 0.2" />
<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>

24
.run/Power.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Power" 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" />
<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="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" />
<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>

24
.run/TCS Off.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TCS Off" 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 pdu1 -o tcs-off -d 3" />
<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>

24
.run/TCS On.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TCS On" 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 pdu1 -o tcs-on -d 3" />
<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,9 @@ class GomspaceDeviceActionIds(enum.IntEnum):
WDT_RESET = 9
REQUEST_HK_TABLE = 16
REQUEST_CONFIG_TABLE = 17
SAVE_TABLE = 18
SAVE_TABLE_DEFAULT = 19
LOAD_TABLE = 20
PRINT_SWITCH_V_I = 32
PRINT_LATCHUPS = 33
@ -35,7 +38,11 @@ class GomspaceOpCodes:
PRINT_SWITCH_V_I = ["print_switch_vi"]
PRINT_LATCHUPS = ["print_latchups"]
GET_PARAM = ["get_param"]
SET_PARAM = ["set_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"]
REQUEST_CONFIG_TABLE = ["cfg_table"]
@ -45,8 +52,12 @@ class GsInfo:
PRINT_SWITCH_V_I = "Print Switch V I Info"
PRINT_LATCHUPS = "Print latchups"
GET_PARAMETER = "Get parameter"
SET_PARAMETER = "Set parameter"
SET_PARAMETER = "Set integer 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)"
LOAD_TABLE = "Load Table"
class SetIds:
@ -60,9 +71,20 @@ class SetIds:
ACU_AUX = 8
class ParamTypes(enum.Enum):
U8 = 0
U16 = 1
U32 = 2
I8 = 3
I16 = 4
I32 = 5
FLOAT = 6
STR = 7
class TableIds:
config = 1
hk = 4
CONFIG = 1
HK = 4
class TableEntry:
@ -70,7 +92,7 @@ class TableEntry:
uint16_size = 2
uint32_size = 4
def __init__(self, parameter_address: bytearray, parameter_size):
def __init__(self, parameter_address: bytes, parameter_size):
self.parameter_address = parameter_address
self.parameter_size = parameter_size
@ -113,34 +135,88 @@ def pack_get_param_command(
)
def pack_set_param_command(
object_id: bytes, memory_address: bytes, parameter_size: int, parameter: int
def pack_set_float_param_command(
object_id: bytes, memory_address: bytes, parameter: float
) -> PusTelecommand:
"""Function to generate a command to set a parameter
:param object_id: The object id of the gomspace device handler.
:param memory_address: Address offset within table of the value to set.
:param parameter: The parameter value to set.
:param parameter_size: Size of the value to set. There are uint8_t, uint16_t and uint32_t
in the device tables.
:return: The command as bytearray.
"""
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(parameter_size)
if parameter_size == 1:
app_data.append(parameter)
elif parameter_size == 2:
app_data += struct.pack("!H", parameter)
elif parameter_size == 4:
byte_one = 0xFF000000 & parameter >> 24
byte_two = 0xFF0000 & parameter >> 16
byte_three = 0xFF00 & parameter >> 8
byte_four = 0xFF & parameter
app_data.append(byte_one)
app_data.append(byte_two)
app_data.append(byte_three)
app_data.append(byte_four)
app_data.append(4)
app_data += struct.pack("!f", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_u8_param_command(
object_id: bytes, memory_address: bytes, parameter: int
) -> PusTelecommand:
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(1)
app_data.append(parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_i8_param_command(
object_id: bytes, memory_address: bytes, parameter: int
) -> PusTelecommand:
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(1)
app_data += struct.pack("!b", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_u16_param_command(
object_id: bytes, memory_address: bytes, parameter: int
) -> PusTelecommand:
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(2)
app_data += struct.pack("!H", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_i16_param_command(
object_id: bytes, memory_address: bytes, parameter: int
) -> PusTelecommand:
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(2)
app_data += struct.pack("!h", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_u32_param_command(object_id: bytes, memory_address: bytes, parameter: int):
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(4)
app_data += struct.pack("!I", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
def pack_set_i32_param_command(object_id: bytes, memory_address: bytes, parameter: int):
action_id = GomspaceDeviceActionIds.PARAM_SET
app_data = bytearray()
app_data += memory_address
app_data.append(4)
app_data += struct.pack("!i", parameter)
return make_fsfw_action_cmd(
object_id=object_id, action_id=action_id, user_data=app_data
)
@ -157,16 +233,27 @@ def prompt_and_pack_get_param_command(q: DefaultPusQueueHelper, object_id: Objec
)
def prompt_and_pack_set_param_command(q: DefaultPusQueueHelper, object_id: ObjectIdU32):
def prompt_and_pack_set_integer_param_command(
q: DefaultPusQueueHelper, object_id: ObjectIdU32, ptype: ParamTypes
):
memory_address = int(input("Specify memory address: 0x"), 16)
memory_address = struct.pack("!H", memory_address)
parameter_size = int(input("Specify parameter size: "))
parameter = int(input("Specify parameter: "))
q.add_pus_tc(
pack_set_param_command(
object_id.as_bytes, memory_address, parameter_size, parameter
)
)
if ptype == ParamTypes.U8:
cmd = pack_set_u8_param_command(object_id.as_bytes, memory_address, parameter)
elif ptype == ParamTypes.U16:
cmd = pack_set_u16_param_command(object_id.as_bytes, memory_address, parameter)
elif ptype == ParamTypes.U32:
cmd = pack_set_u16_param_command(object_id.as_bytes, memory_address, parameter)
elif ptype == ParamTypes.I8:
cmd = pack_set_i8_param_command(object_id.as_bytes, memory_address, parameter)
elif ptype == ParamTypes.I16:
cmd = pack_set_i16_param_command(object_id.as_bytes, memory_address, parameter)
elif ptype == ParamTypes.I32:
cmd = pack_set_i32_param_command(object_id.as_bytes, memory_address, parameter)
else:
raise ValueError(f"Invalid parameter type {ptype} for this function")
q.add_pus_tc(cmd)
def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand:
@ -184,7 +271,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

@ -2,20 +2,30 @@ from gomspace.gomspace_common import TableEntry
class PduConfigTable:
out_en_0 = TableEntry(bytearray([0x00, 0x48]), TableEntry.uint8_size)
out_en_1 = TableEntry(bytearray([0x00, 0x49]), TableEntry.uint8_size)
out_en_2 = TableEntry(bytearray([0x00, 0x4A]), TableEntry.uint8_size)
out_en_3 = TableEntry(bytearray([0x00, 0x4B]), TableEntry.uint8_size)
out_en_4 = TableEntry(bytearray([0x00, 0x4C]), TableEntry.uint8_size)
out_en_5 = TableEntry(bytearray([0x00, 0x4D]), TableEntry.uint8_size)
out_en_6 = TableEntry(bytearray([0x00, 0x4E]), TableEntry.uint8_size)
out_en_7 = TableEntry(bytearray([0x00, 0x4F]), TableEntry.uint8_size)
out_en_8 = TableEntry(bytearray([0x00, 0x50]), TableEntry.uint8_size)
# When channel consumes more than cur_lu_lim, channel is turned of immediately
out_en_0 = TableEntry(bytes([0x00, 0x48]), TableEntry.uint8_size)
out_en_1 = TableEntry(bytes([0x00, 0x49]), TableEntry.uint8_size)
out_en_2 = TableEntry(bytes([0x00, 0x4A]), TableEntry.uint8_size)
out_en_3 = TableEntry(bytes([0x00, 0x4B]), TableEntry.uint8_size)
out_en_4 = TableEntry(bytes([0x00, 0x4C]), TableEntry.uint8_size)
out_en_5 = TableEntry(bytes([0x00, 0x4D]), TableEntry.uint8_size)
out_en_6 = TableEntry(bytes([0x00, 0x4E]), TableEntry.uint8_size)
out_en_7 = TableEntry(bytes([0x00, 0x4F]), TableEntry.uint8_size)
out_en_8 = TableEntry(bytes([0x00, 0x50]), TableEntry.uint8_size)
# When channel consumes more than cur_lu_lim, channel is turned off immediately
cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xB8]), TableEntry.uint16_size)
INIT_OUT_SAFE_CH_0 = TableEntry(bytes([0x00, 0x80]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_1 = TableEntry(bytes([0x00, 0x80 + 1]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_2 = TableEntry(bytes([0x00, 0x80 + 2]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_3 = TableEntry(bytes([0x00, 0x80 + 3]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_4 = TableEntry(bytes([0x00, 0x80 + 4]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_5 = TableEntry(bytes([0x00, 0x80 + 5]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_6 = TableEntry(bytes([0x00, 0x80 + 6]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_7 = TableEntry(bytes([0x00, 0x80 + 7]), TableEntry.uint8_size)
INIT_OUT_SAFE_CH_8 = TableEntry(bytes([0x00, 0x80 + 8]), TableEntry.uint8_size)
PDU_CONFIG_LIST = [
OUT_ENABLE_LIST = [
PduConfigTable.out_en_0,
PduConfigTable.out_en_1,
PduConfigTable.out_en_2,

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)
@ -111,7 +111,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
gs.TableIds.HK,
ACUHkTable.wdt_gnd_left.parameter_address,
ACUHkTable.wdt_gnd_left.parameter_size,
)
@ -128,7 +128,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
gs.TableIds.HK,
ACUHkTable.temperature3.parameter_address,
ACUHkTable.temperature3.parameter_size,
)
@ -138,7 +138,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
gs.TableIds.CONFIG,
ACUConfigTable.vboost.parameter_address,
ACUConfigTable.vboost.parameter_size,
)
@ -148,7 +148,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
gs.TableIds.CONFIG,
ACUConfigTable.vbat_max_hi.parameter_address,
ACUConfigTable.vbat_max_hi.parameter_size,
)
@ -158,7 +158,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
gs.TableIds.CONFIG,
ACUConfigTable.vbat_max_lo.parameter_address,
ACUConfigTable.vbat_max_lo.parameter_size,
)
@ -168,7 +168,7 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
gs.TableIds.CONFIG,
ACUConfigTable.ov_mode.parameter_address,
ACUConfigTable.ov_mode.parameter_size,
)

View File

@ -1,14 +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 (
@ -17,58 +20,60 @@ 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:
# 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"]
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
@ -86,15 +91,95 @@ def add_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)
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]: "
)
)
if source_table not in [0, 1, 2, 4]:
raise ValueError("Invalid source table index")
# 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]: "
)
)
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,
action_id=GomspaceDeviceActionIds.SAVE_TABLE_DEFAULT,
user_data=bytes([source_table]),
)
)
if op_code in GomspaceOpCodes.LOAD_TABLE:
target_table = int(
input(
"Target table ID [0: Board Config, 1: Module Config, 2: Calibration Parameter, "
"4: HK TM]: "
)
)
if target_table not in [0, 1, 2, 4]:
raise ValueError("Invalid source table index")
if target_table != 4:
source_table = int(
input(
"Source table (file or default) [0: Board Config, 1: Module Config, "
"2: Calibration Parameter, value + 4 for default table]: "
)
)
if source_table not in [0, 1, 2, 4, 5, 6]:
raise ValueError("Invalid source table index")
else:
# Will be ignored
source_table = 4
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=object_id.as_bytes,
action_id=GomspaceDeviceActionIds.LOAD_TABLE,
user_data=bytes([source_table, target_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(
@ -114,15 +199,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,
)
)
@ -133,10 +221,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,
)
)
@ -153,5 +240,9 @@ 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)
oce.add(keys=GomspaceOpCodes.LOAD_TABLE, info=GsInfo.LOAD_TABLE)
oce.add(keys=GomspaceOpCodes.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG)

View File

@ -5,17 +5,18 @@
@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,
Channel,
pack_set_param_command,
TableIds,
pack_get_param_command,
pack_gnd_wdt_reset_command,
pack_ping_command,
pack_reboot_command,
pack_set_u8_param_command,
pack_set_u16_param_command,
SetIds,
)
from config.object_ids import P60_DOCK_HANDLER
@ -95,45 +96,41 @@ 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)
q.add_pus_tc(
pack_set_param_command(
pack_set_u8_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(
pack_set_u8_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(
pack_set_u8_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(
pack_set_u8_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.off,
)
)
@ -145,7 +142,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
TableIds.HK,
P60DockHkTable.wdt_gnd_left.parameter_address,
P60DockHkTable.wdt_gnd_left.parameter_size,
)
@ -161,10 +158,9 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
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(
pack_set_u8_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
@ -173,7 +169,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
TableIds.HK,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
@ -183,7 +179,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
TableIds.CONFIG,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
)
@ -193,7 +189,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
TableIds.CONFIG,
P60DockConfigTable.cur_lu_lim_0.parameter_address,
P60DockConfigTable.cur_lu_lim_0.parameter_size,
)
@ -202,10 +198,9 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
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(
pack_set_u8_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
@ -226,43 +221,15 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code:
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
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,
)
)
q.add_pus_tc(pack_set_u16_param_command(objb, invalid_address, parameter))
def p60_dock_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):

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])
@ -71,51 +71,11 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
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,
)
)
def pdu1_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):

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,
@ -31,6 +31,7 @@ class Pdu2InfoBase:
class Pdu2ChIndex(enum.IntEnum):
OBC = 0
PL_PCDU_BAT_NOM = 1
RW = 2
HEATER = 3
@ -73,7 +74,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))
@ -82,7 +83,7 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
TableIds.HK,
PduHkTable.wdt_gnd_left.parameter_address,
PduHkTable.wdt_gnd_left.parameter_size,
)
@ -94,22 +95,12 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
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,
TableIds.HK,
PduHkTable.temperature.parameter_address,
PduHkTable.temperature.parameter_size,
)
@ -119,7 +110,7 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
TableIds.CONFIG,
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
)
@ -129,21 +120,11 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
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

@ -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,13 @@ 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])
q.add_wait_seconds(5.0)
if q.empty():
LOGGER.info(f"Queue is empty, no stack for op code {op_code}")
@ -70,6 +85,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",

View File

@ -461,14 +461,22 @@ def handle_get_param_data_reply(
elif action_id == GomspaceDeviceActionIds.REQUEST_CONFIG_TABLE:
print(f"Received config table with size {len(custom_data)} for object {obj_id}")
if obj_id.as_bytes == PDU_1_HANDLER_ID or obj_id.as_bytes == PDU_2_HANDLER_ID:
pdu_config_table_handler(pw, custom_data)
pdu_config_table_handler(pw, custom_data, obj_id)
elif obj_id.as_bytes == ACU_HANDLER_ID:
acu_config_table_handler(pw, custom_data)
elif obj_id.as_bytes == P60_DOCK_HANDLER:
p60_dock_config_table_handler(pw, custom_data)
def pdu_config_table_handler(pw: PrintWrapper, custom_data: bytes):
def pdu_config_table_handler(
pw: PrintWrapper, custom_data: bytes, obj_id: ObjectIdBase
):
if obj_id.as_bytes == PDU_1_HANDLER_ID:
pw.dlog("[tcs, syrlinks, str, mgt, sus-n, scex, ploc, acs-a, unused]")
elif obj_id.as_bytes == PDU_2_HANDLER_ID:
pw.dlog(
"[obc, pl-pcdu-bat-nom, rw, heaters, sus-r, sa-depl, pl-pcdu-bat-red, acs-b, pl-cam]"
)
out_on_cnt = unpack_array_in_data(custom_data, 0x52, 2, 9, "H")
out_off_cnt = unpack_array_in_data(custom_data, 0x64, 2, 9, "H")
init_out_norm = unpack_array_in_data(custom_data, 0x76, 1, 9, "B")
@ -476,6 +484,11 @@ def pdu_config_table_handler(pw: PrintWrapper, custom_data: bytes):
init_on_dly = unpack_array_in_data(custom_data, 0x8A, 2, 9, "H")
init_off_dly = unpack_array_in_data(custom_data, 0x9C, 2, 9, "H")
safe_off_dly = unpack_array_in_data(custom_data, 0xAE, 1, 9, "B")
cur_lu_lim = unpack_array_in_data(custom_data, 0xB8, 2, 9, "H")
cur_lim = unpack_array_in_data(custom_data, 0xCA, 2, 9, "H")
cur_ema = unpack_array_in_data(custom_data, 0xDC, 2, 9, "H")
wdt_can_rst = custom_data[0x127]
wdt_can = struct.unpack(f"{OBC_ENDIANNESS}I", custom_data[0x12C : 0x12C + 4])[0]
batt_hwmax = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x11C : 0x11C + 2])[0]
batt_max = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x11E : 0x11E + 2])[0]
batt_norm = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x120 : 0x120 + 2])[0]
@ -488,11 +501,16 @@ def pdu_config_table_handler(pw: PrintWrapper, custom_data: bytes):
pw.dlog(f"{'init_on_dly'.ljust(15)}: {init_on_dly}")
pw.dlog(f"{'init_off_dly'.ljust(15)}: {init_off_dly}")
pw.dlog(f"{'safe_off_dly'.ljust(15)}: {safe_off_dly}")
pw.dlog(f"{'cur_lu_lim'.ljust(15)}: {cur_lu_lim}")
pw.dlog(f"{'cur_lim'.ljust(15)}: {cur_lim}")
pw.dlog(f"{'cur_ema'.ljust(15)}: {cur_ema}")
pw.dlog(f"{'batt_hwmax'.ljust(15)}: {batt_hwmax}")
pw.dlog(f"{'batt_max'.ljust(15)}: {batt_max}")
pw.dlog(f"{'batt_norm'.ljust(15)}: {batt_norm}")
pw.dlog(f"{'batt_safe'.ljust(15)}: {batt_safe}")
pw.dlog(f"{'batt_crit'.ljust(15)}: {batt_crit}")
pw.dlog(f"{'wdt_can_rst'.ljust(15)}: {wdt_can_rst}")
pw.dlog(f"{'wdt_can'.ljust(15)}: {wdt_can}")
def acu_config_table_handler(pw: PrintWrapper, custom_data: bytes):