diff --git a/.run/ACU.run.xml b/.run/ACU.run.xml
index 92b80ba..4efad3b 100644
--- a/.run/ACU.run.xml
+++ b/.run/ACU.run.xml
@@ -21,4 +21,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tmtc/power/acu.py b/tmtc/power/acu.py
index 9da4bc5..ddcba2c 100644
--- a/tmtc/power/acu.py
+++ b/tmtc/power/acu.py
@@ -3,14 +3,18 @@
@author J. Meier, R. Mueller
@date 21.12.2020
"""
+import struct
from config.definitions import CustomServiceList
+from pus_tm.defs import PrintWrapper
from tmtc.power.common_power import (
pack_common_gomspace_cmds,
add_gomspace_cmd_defs,
req_hk_cmds,
pack_common_power_cmds,
SetIds,
+ OBC_ENDIANNESS,
+ unpack_array_in_data,
)
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
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,
)
)
+
+
+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}")
diff --git a/tmtc/power/common_power.py b/tmtc/power/common_power.py
index 59f6b2c..61eba98 100644
--- a/tmtc/power/common_power.py
+++ b/tmtc/power/common_power.py
@@ -1,3 +1,6 @@
+import struct
+from typing import List
+
from gomspace.gomspace_common import (
pack_set_u8_param_command,
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.LOAD_TABLE, info=GsInfo.LOAD_TABLE)
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)
+ ]
diff --git a/tmtc/power/tm.py b/tmtc/power/tm.py
index 93f32d2..d3079ce 100644
--- a/tmtc/power/tm.py
+++ b/tmtc/power/tm.py
@@ -1,7 +1,8 @@
import struct
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.tmtc_printer import FsfwTmTcPrinter
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)
-OBC_ENDIANNESS = "<"
-
-
def handle_get_param_data_reply(
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}")
-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):
ch_names = parse_name_list(custom_data[0:0x68], 13)
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 += 1
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)
- ]