This commit is contained in:
Robin Müller 2022-11-14 17:10:30 +01:00
commit 66a1362e7e
4 changed files with 65 additions and 35 deletions

View File

@ -21,4 +21,26 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration default="false" name="ACU" 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 acu -l" />
<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> </component>

View File

@ -3,14 +3,18 @@
@author J. Meier, R. Mueller @author J. Meier, R. Mueller
@date 21.12.2020 @date 21.12.2020
""" """
import struct
from config.definitions import CustomServiceList from config.definitions import CustomServiceList
from pus_tm.defs import PrintWrapper
from tmtc.power.common_power import ( from tmtc.power.common_power import (
pack_common_gomspace_cmds, pack_common_gomspace_cmds,
add_gomspace_cmd_defs, add_gomspace_cmd_defs,
req_hk_cmds, req_hk_cmds,
pack_common_power_cmds, pack_common_power_cmds,
SetIds, SetIds,
OBC_ENDIANNESS,
unpack_array_in_data,
) )
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.config.tmtc import tmtc_definitions_provider
@ -165,3 +169,22 @@ def pack_test_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
ACUConfigTable.ov_mode.parameter_size, ACUConfigTable.ov_mode.parameter_size,
) )
) )
def acu_config_table_handler(pw: PrintWrapper, custom_data: bytes):
mppt_mode = custom_data[0]
mppt_delta_mode = custom_data[1]
vboost_list = unpack_array_in_data(custom_data, 0x02, 2, 6, "H")
vbat_max_hi = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x10 : 0x10 + 2])[0]
vbat_max_lo = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x12 : 0x12 + 2])[0]
mppt_period = struct.unpack(f"{OBC_ENDIANNESS}I", custom_data[0x14 : 0x14 + 4])[0]
max_dv = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x18 : 0x18 + 2])[0]
ov_mode = custom_data[0x1A]
pw.dlog(f"{'mppt_mode'.ljust(15)}: {mppt_mode}")
pw.dlog(f"{'mppt_delta_mode'.ljust(15)}: {mppt_delta_mode}")
pw.dlog(f"{'vboost_list'.ljust(15)}: {vboost_list}")
pw.dlog(f"{'vbat_max_hi'.ljust(15)}: {vbat_max_hi}")
pw.dlog(f"{'vbat_max_lo'.ljust(15)}: {vbat_max_lo}")
pw.dlog(f"{'mppt_period'.ljust(15)}: {mppt_period}")
pw.dlog(f"{'max_dv'.ljust(15)}: {max_dv}")
pw.dlog(f"{'ov_mode'.ljust(15)}: {ov_mode}")

View File

@ -1,3 +1,6 @@
import struct
from typing import List
from gomspace.gomspace_common import ( from gomspace.gomspace_common import (
pack_set_u8_param_command, pack_set_u8_param_command,
Channel, Channel,
@ -309,3 +312,18 @@ def add_gomspace_cmd_defs(oce: OpCodeEntry):
oce.add(keys=GomspaceOpCodes.SAVE_TABLE_DEFAULT, info=GsInfo.SAVE_TABLE_DEFAULT) 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.LOAD_TABLE, info=GsInfo.LOAD_TABLE)
oce.add(keys=GomspaceOpCodes.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG) oce.add(keys=GomspaceOpCodes.RESET_GND_WATCHDOG, info=GsInfo.RESET_GND_WATCHDOG)
OBC_ENDIANNESS = "<"
def unpack_array_in_data(
data: bytes, start_addr: int, width: int, entries: int, struct_spec: str
) -> List:
return [
struct.unpack(
f"{OBC_ENDIANNESS}{struct_spec}",
data[start_addr + (i * width) : start_addr + ((i + 1) * width)],
)[0]
for i in range(entries)
]

View File

@ -1,7 +1,8 @@
import struct import struct
from typing import List, Tuple from typing import List, Tuple
from tmtc.power.common_power import SetIds from tmtc.power.acu import acu_config_table_handler
from tmtc.power.common_power import SetIds, unpack_array_in_data, OBC_ENDIANNESS
from tmtccmd.util import ObjectIdBase from tmtccmd.util import ObjectIdBase
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from pus_tm.defs import PrintWrapper from pus_tm.defs import PrintWrapper
@ -431,9 +432,6 @@ def handle_acu_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=8) printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=8)
OBC_ENDIANNESS = "<"
def handle_get_param_data_reply( def handle_get_param_data_reply(
obj_id: ObjectIdBase, action_id: int, pw: PrintWrapper, custom_data: bytearray obj_id: ObjectIdBase, action_id: int, pw: PrintWrapper, custom_data: bytearray
): ):
@ -514,25 +512,6 @@ def pdu_config_table_handler(
pw.dlog(f"{'wdt_can'.ljust(15)}: {wdt_can}") pw.dlog(f"{'wdt_can'.ljust(15)}: {wdt_can}")
def acu_config_table_handler(pw: PrintWrapper, custom_data: bytes):
mppt_mode = custom_data[0]
mppt_delta_mode = custom_data[1]
vboost_list = unpack_array_in_data(custom_data, 0x02, 2, 6, "H")
vbat_max_hi = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x10 : 0x10 + 2])[0]
vbat_max_lo = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x12 : 0x12 + 2])[0]
mppt_period = struct.unpack(f"{OBC_ENDIANNESS}I", custom_data[0x14 : 0x14 + 4])[0]
max_dv = struct.unpack(f"{OBC_ENDIANNESS}H", custom_data[0x18 : 0x18 + 2])[0]
ov_mode = custom_data[0x1A]
pw.dlog(f"{'mppt_mode'.ljust(15)}: {mppt_mode}")
pw.dlog(f"{'mppt_delta_mode'.ljust(15)}: {mppt_delta_mode}")
pw.dlog(f"{'vboost_list'.ljust(15)}: {vboost_list}")
pw.dlog(f"{'vbat_max_hi'.ljust(15)}: {vbat_max_hi}")
pw.dlog(f"{'vbat_max_lo'.ljust(15)}: {vbat_max_lo}")
pw.dlog(f"{'mppt_period'.ljust(15)}: {mppt_period}")
pw.dlog(f"{'max_dv'.ljust(15)}: {max_dv}")
pw.dlog(f"{'ov_mode'.ljust(15)}: {ov_mode}")
def p60_dock_config_table_handler(pw: PrintWrapper, custom_data: bytes): def p60_dock_config_table_handler(pw: PrintWrapper, custom_data: bytes):
ch_names = parse_name_list(custom_data[0:0x68], 13) ch_names = parse_name_list(custom_data[0:0x68], 13)
out_on_cnt = unpack_array_in_data(custom_data, 0x76, 2, 13, "H") out_on_cnt = unpack_array_in_data(custom_data, 0x76, 2, 13, "H")
@ -571,15 +550,3 @@ def parse_name_list(data: bytes, name_len: int):
idx += len(name) idx += len(name)
idx += 1 idx += 1
return ch_list return ch_list
def unpack_array_in_data(
data: bytes, start_addr: int, width: int, entries: int, struct_spec: str
) -> List:
return [
struct.unpack(
f"{OBC_ENDIANNESS}{struct_spec}",
data[start_addr + (i * width) : start_addr + ((i + 1) * width)],
)[0]
for i in range(entries)
]