add command to set preferred SD card
This commit is contained in:
parent
01b3a894e6
commit
a5178e2bb0
@ -11,6 +11,10 @@ from tmtccmd.config import TmtcDefinitionWrapper
|
||||
from tmtccmd.tc import DefaultPusQueueHelper
|
||||
from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
|
||||
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
|
||||
from tmtccmd.tc.pus_20_fsfw_param import (
|
||||
create_scalar_u8_parameter,
|
||||
create_load_param_cmd,
|
||||
)
|
||||
from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider
|
||||
from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID
|
||||
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
||||
@ -37,6 +41,10 @@ class ActionId(enum.IntEnum):
|
||||
FULL_REBOOT = 34
|
||||
|
||||
|
||||
class ParamId(enum.IntEnum):
|
||||
PREF_SD = 0
|
||||
|
||||
|
||||
class SetId(enum.IntEnum):
|
||||
HK = 5
|
||||
|
||||
@ -45,6 +53,7 @@ class OpCode:
|
||||
ANNOUNCE_VERSION = "announce_version"
|
||||
ANNOUNCE_CURRENT_IMAGE = "announce_current_image"
|
||||
ANNOUNCE_BOOT_COUNTS = "announce_boot_counts"
|
||||
SET_PREF_SD = "set_pref_sd"
|
||||
REBOOT_XSC = ["reboot_xsc"]
|
||||
XSC_REBOOT_SELF = ["reboot_self"]
|
||||
XSC_REBOOT_0_0 = ["reboot_00"]
|
||||
@ -73,6 +82,7 @@ class Info:
|
||||
ANNOUNCE_VERSION = "Announce version"
|
||||
ANNOUNCE_CURRENT_IMAGE = "Announce current image"
|
||||
ANNOUNCE_BOOT_COUNTS = "Announce boot counts"
|
||||
SET_PREF_SD = "Set preferred SD card"
|
||||
REBOOT_XSC = "XSC reboot with prompt"
|
||||
REBOOT_FULL = "Full regular reboot"
|
||||
OBSW_UPDATE_FROM_SD_0 = "Update OBSW from SD Card 0"
|
||||
@ -109,6 +119,7 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
|
||||
oce.add(keys=OpCode.XSC_REBOOT_0_1, info="Reboot 0 1")
|
||||
oce.add(keys=OpCode.XSC_REBOOT_1_0, info="Reboot 1 0")
|
||||
oce.add(keys=OpCode.XSC_REBOOT_1_1, info="Reboot 1 1")
|
||||
oce.add(keys=OpCode.SET_PREF_SD, info=Info.SET_PREF_SD)
|
||||
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)
|
||||
@ -283,6 +294,23 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
|
||||
q.add_log_cmd("Requesting housekeeping set")
|
||||
sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetId.HK)
|
||||
q.add_pus_tc(generate_one_hk_command(sid))
|
||||
elif op_code in OpCode.SET_PREF_SD:
|
||||
q.add_log_cmd("Set preferred SD card")
|
||||
pref_sd = int(
|
||||
input("Specify which SD card to set as the preferred one (0/1): ")
|
||||
)
|
||||
if pref_sd not in [0, 1]:
|
||||
raise ValueError("Only 0 or 1 allowed for preferred SD card")
|
||||
q.add_pus_tc(
|
||||
create_load_param_cmd(
|
||||
create_scalar_u8_parameter(
|
||||
object_id=CORE_CONTROLLER_ID,
|
||||
domain_id=0,
|
||||
unique_id=ParamId.PREF_SD,
|
||||
parameter=pref_sd,
|
||||
).pack()
|
||||
)
|
||||
)
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
f"Unknown operation code {op_code} for core controller commands"
|
||||
|
Loading…
Reference in New Issue
Block a user