OBSW Update Commands #114

Merged
meierj merged 16 commits from mueller/obsw-update-cmds into main 2022-09-29 13:30:37 +02:00
Showing only changes of commit 801afb9550 - Show all commits

View File

@ -24,6 +24,9 @@ class ActionIds(enum.IntEnum):
UPDATE_OBSW_FROM_SD_0 = 10
UPDATE_OBSW_FROM_SD_1 = 11
UPDATE_OBSW_FROM_TMP = 12
SWITCH_TO_SD_0 = 16
SWITCH_TO_SD_1 = 17
SWITCH_TO_BOTH_SD_CARDS = 18
XSC_REBOOT = 32
FULL_REBOOT = 34
@ -44,6 +47,9 @@ class OpCodes:
OBSW_UPDATE_FROM_SD_0 = ["obsw_update_sd0"]
OBSW_UPDATE_FROM_SD_1 = ["obsw_update_sd1"]
OBSW_UPDATE_FROM_TMP = ["obsw_update_tmp"]
SWITCH_TO_SD_0 = ["switch_to_sd_0"]
SWITCH_TO_SD_1 = ["switch_to_sd_1"]
SWITCH_TO_BOTH_SD_CARDS = ["switch_to_both_sd_cards"]
ENABLE_REBOOT_FILE_HANDLING = ["32", "rbh_off"]
DISABLE_REBOOT_FILE_HANDLING = ["33", "rbh_on"]
RESET_ALL_REBOOT_COUNTERS = ["34", "rbh_reset_a"]
@ -60,6 +66,9 @@ class Info:
OBSW_UPDATE_FROM_SD_0 = "Update OBSW from SD Card 0"
OBSW_UPDATE_FROM_SD_1 = "Update OBSW from SD Card 1"
OBSW_UPDATE_FROM_TMP = "Update OBSW from tmp folder"
SWITCH_TO_SD_0 = "Switch to SD card 0"
SWITCH_TO_SD_1 = "Switch to SD card 1"
SWITCH_TO_BOTH_SD_CARDS = "Switch to both SD cards with specified active card"
class Chip(enum.IntEnum):
@ -120,6 +129,9 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCodes.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0)
oce.add(keys=OpCodes.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1)
oce.add(keys=OpCodes.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
oce.add(keys=OpCodes.SWITCH_TO_SD_0, info=Info.SWITCH_TO_SD_0)
oce.add(keys=OpCodes.SWITCH_TO_SD_1, info=Info.SWITCH_TO_SD_1)
oce.add(keys=OpCodes.SWITCH_TO_BOTH_SD_CARDS, info=Info.SWITCH_TO_BOTH_SD_CARDS)
defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce)
@ -208,6 +220,34 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
if op_code in OpCodes.OBSW_UPDATE_FROM_TMP:
q.add_log_cmd(Info.OBSW_UPDATE_FROM_TMP)
q.add_pus_tc(pack_obsw_update_cmd(ActionIds.UPDATE_OBSW_FROM_TMP))
if op_code in OpCodes.SWITCH_TO_SD_0:
q.add_log_cmd(Info.SWITCH_TO_SD_0)
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.SWITCH_TO_SD_0
)
)
if op_code in OpCodes.SWITCH_TO_SD_1:
q.add_log_cmd(Info.SWITCH_TO_SD_1)
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.SWITCH_TO_SD_1
)
)
if op_code in OpCodes.SWITCH_TO_BOTH_SD_CARDS:
while True:
active_sd_card = int(input("Please specify active SD cqrd [0/1]: "))
if active_sd_card not in [0, 1]:
LOGGER.warning("Invalid SD card specified. Try again")
break
q.add_log_cmd(Info.SWITCH_TO_BOTH_SD_CARDS)
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=CORE_CONTROLLER_ID,
action_id=ActionIds.SWITCH_TO_BOTH_SD_CARDS,
user_data=bytes([active_sd_card]),
)
)
if op_code in OpCodes.GET_HK:
q.add_log_cmd("Requesting housekeeping set")
sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetIds.HK)