From 6085c6543c0beb24cc427fae16d1fa2897a2fe5a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 17:31:24 +0200 Subject: [PATCH] add command to load table --- gomspace/gomspace_common.py | 3 +++ tmtc/power/common_power.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 807f6cd..0c1e0a8 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -26,6 +26,7 @@ class GomspaceDeviceActionIds(enum.IntEnum): REQUEST_CONFIG_TABLE = 17 SAVE_TABLE = 18 SAVE_TABLE_DEFAULT = 19 + LOAD_TABLE = 20 PRINT_SWITCH_V_I = 32 PRINT_LATCHUPS = 33 @@ -41,6 +42,7 @@ class GomspaceOpCodes: 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"] @@ -55,6 +57,7 @@ class GsInfo: 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: diff --git a/tmtc/power/common_power.py b/tmtc/power/common_power.py index bf6caeb..bfca314 100644 --- a/tmtc/power/common_power.py +++ b/tmtc/power/common_power.py @@ -142,6 +142,34 @@ def pack_gomspace_cmds( 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, " + "value + 4 for default table]: " + ) + ) + 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)) @@ -216,4 +244,5 @@ def add_gomspace_cmd_defs(oce: OpCodeEntry): 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)