From f400dea7994e82b44b1de439de7b6d206dc1f3d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Oct 2023 15:01:23 +0200 Subject: [PATCH 1/3] done --- eive_tmtc/tmtc/core.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index 6a85ce2..070f09f 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -3,6 +3,7 @@ import logging import os import struct from pathlib import Path +from typing import Tuple from eive_tmtc.pus_tm.defs import PrintWrapper @@ -52,6 +53,8 @@ class ActionId(enum.IntEnum): SWITCH_TO_SD_0 = 16 SWITCH_TO_SD_1 = 17 SWITCH_TO_BOTH_SD_CARDS = 18 + AUTO_SWITCH_ENABLE = 19 + AUTO_SWITCH_DISABLE = 20 XSC_REBOOT = 32 FULL_REBOOT = 34 EXECUTE_SHELL_CMD_BLOCKING = 40 @@ -110,6 +113,8 @@ class OpCode: RWD_RESET_REBOOT_COUNTER_10 = "rwd_reset_10" RWD_RESET_REBOOT_COUNTER_11 = "rwd_reset_11" RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt" + AUTO_SWITCH_ENABLE = "auto_switch_enable" + AUTO_SWITCH_DISABLE = "auto_switch_disable" class Info: @@ -135,6 +140,8 @@ class Info: MV_HELPER = "Filesystem Move Helper" RM_HELPER = "Filesystem Removal Helper" MKDIR_HELPER = "Filesystem Directory Creation Helper" + AUTO_SWITCH_ENABLE = "Enable Auto-Switch Feature with a specific target image" + AUTO_SWITCH_DISABLE = "Disable Auto-Switch Feature" class Chip(enum.IntEnum): @@ -176,6 +183,8 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper): oce.add(keys=OpCode.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP) oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0) oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1) + oce.add(keys=OpCode.AUTO_SWITCH_ENABLE, info=Info.AUTO_SWITCH_ENABLE) + oce.add(keys=OpCode.AUTO_SWITCH_DISABLE, info=Info.AUTO_SWITCH_DISABLE) oce.add(keys=OpCode.SYSTEMCTL_CMD_EXECUTOR, info=Info.SYSTEMCTL_CMD_EXECUTOR) oce.add( keys=OpCode.EXECUTE_SHELL_CMD_BLOCKING, info=Info.EXECUTE_SHELL_CMD_BLOCKING @@ -381,6 +390,19 @@ def pack_core_commands( # noqa C901 elif op_code in OpCode.OBSW_UPDATE_FROM_TMP: q.add_log_cmd(Info.OBSW_UPDATE_FROM_TMP) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_TMP)) + elif op_code in OpCode.AUTO_SWITCH_ENABLE: + q.add_log_cmd(Info.AUTO_SWITCH_ENABLE) + chip, copy = determine_chip_and_copy() + user_data = bytes([chip, copy]) + q.add_pus_tc( + create_action_cmd( + CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_ENABLE, user_data + ) + ) + elif op_code in OpCode.AUTO_SWITCH_DISABLE: + q.add_pus_tc( + create_action_cmd(CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_DISABLE) + ) elif op_code in OpCode.SWITCH_TO_SD_0: q.add_log_cmd(Info.SWITCH_TO_SD_0) q.add_pus_tc( @@ -551,18 +573,17 @@ def create_full_reboot_cmds() -> PusTelecommand: ) -def determine_reboot_params() -> (bool, Chip, Copy): - chip_select = -1 - copy_select = -1 +def determine_reboot_params() -> Tuple[bool, Chip, Copy]: reboot_self = input("Reboot self? [y/n]: ") if reboot_self in ["y", "yes", "1"]: _LOGGER.info("Rebooting currently running image") - return True, chip_select, copy_select + return True, Chip.NONE, Copy.NONE _LOGGER.info("Rebooting image specified by chip and copy") - return False, determine_chip_and_copy() + chip, copy = determine_chip_and_copy() + return False, chip, copy -def determine_chip_and_copy() -> (int, int): +def determine_chip_and_copy() -> Tuple[Chip, Copy]: while True: chip_select = input("Chip select [0/1]: ") if chip_select in ["0", "1"]: From a5e38a6856dc5238dc56c2463e6c865624a3191d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Oct 2023 15:02:24 +0200 Subject: [PATCH 2/3] missing log printout --- eive_tmtc/tmtc/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index 070f09f..5088768 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -400,6 +400,7 @@ def pack_core_commands( # noqa C901 ) ) elif op_code in OpCode.AUTO_SWITCH_DISABLE: + q.add_log_cmd(Info.AUTO_SWITCH_DISABLE) q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_DISABLE) ) From 728b7c647cf826d0dd751126935c1cb559aa16ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Oct 2023 15:02:50 +0200 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77648b2..36a2446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ list yields a list of all related PRs for each release. # [unreleased] +## Added + +- Core controller auto switch enable and disable command. + # [v5.8.0] 2023-10-11 ## Added