add TMTC commands for OBSW update
This commit is contained in:
parent
847a9dc000
commit
947f377147
@ -1,6 +1,7 @@
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
from config.definitions import CustomServiceList
|
from config.definitions import CustomServiceList
|
||||||
|
from spacepackets.ecss import PusTelecommand
|
||||||
from tmtccmd.config import TmtcDefinitionWrapper
|
from tmtccmd.config import TmtcDefinitionWrapper
|
||||||
|
|
||||||
from tmtccmd.tc import DefaultPusQueueHelper
|
from tmtccmd.tc import DefaultPusQueueHelper
|
||||||
@ -17,12 +18,12 @@ LOGGER = get_console_logger()
|
|||||||
class ActionIds(enum.IntEnum):
|
class ActionIds(enum.IntEnum):
|
||||||
LIST_DIR_INTO_FILE = 0
|
LIST_DIR_INTO_FILE = 0
|
||||||
SWITCH_REBOOT_FILE_HANDLING = 5
|
SWITCH_REBOOT_FILE_HANDLING = 5
|
||||||
RESET_ALL_REBOOT_COUNTERS = 6
|
RESET_REBOOT_COUNTER = 6
|
||||||
RESET_REBOOT_COUNTER_00 = 7
|
SWITCH_IMG_LOCK = 7
|
||||||
RESET_REBOOT_COUNTER_01 = 8
|
SET_MAX_REBOOT_CNT = 8
|
||||||
RESET_REBOOT_COUNTER_10 = 9
|
UPDATE_OBSW_FROM_SD_0 = 10
|
||||||
RESET_REBOOT_COUNTER_11 = 10
|
UPDATE_OBSW_FROM_SD_1 = 11
|
||||||
SET_MAX_REBOOT_CNT = 11
|
UPDATE_OBSW_FROM_TMP = 12
|
||||||
XSC_REBOOT = 32
|
XSC_REBOOT = 32
|
||||||
FULL_REBOOT = 34
|
FULL_REBOOT = 34
|
||||||
|
|
||||||
@ -40,6 +41,9 @@ class OpCodes:
|
|||||||
XSC_REBOOT_1_1 = ["5", "reboot_11"]
|
XSC_REBOOT_1_1 = ["5", "reboot_11"]
|
||||||
REBOOT_FULL = ["6", "reboot_regular"]
|
REBOOT_FULL = ["6", "reboot_regular"]
|
||||||
GET_HK = ["7", "get_hk"]
|
GET_HK = ["7", "get_hk"]
|
||||||
|
OBSW_UPDATE_FROM_SD_0 = ["obsw_update_sd0"]
|
||||||
|
OBSW_UPDATE_FROM_SD_1 = ["obsw_update_sd1"]
|
||||||
|
OBSW_UPDATE_FROM_TMP = ["obsw_update_tmp"]
|
||||||
ENABLE_REBOOT_FILE_HANDLING = ["32", "rbh_off"]
|
ENABLE_REBOOT_FILE_HANDLING = ["32", "rbh_off"]
|
||||||
DISABLE_REBOOT_FILE_HANDLING = ["33", "rbh_on"]
|
DISABLE_REBOOT_FILE_HANDLING = ["33", "rbh_on"]
|
||||||
RESET_ALL_REBOOT_COUNTERS = ["34", "rbh_reset_a"]
|
RESET_ALL_REBOOT_COUNTERS = ["34", "rbh_reset_a"]
|
||||||
@ -53,6 +57,9 @@ class OpCodes:
|
|||||||
class Info:
|
class Info:
|
||||||
REBOOT_XSC = "XSC reboot with prompt"
|
REBOOT_XSC = "XSC reboot with prompt"
|
||||||
REBOOT_FULL = "Full regular reboot"
|
REBOOT_FULL = "Full regular reboot"
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
||||||
class Chip(enum.IntEnum):
|
class Chip(enum.IntEnum):
|
||||||
@ -110,6 +117,9 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
|
|||||||
keys=OpCodes.RESET_REBOOT_COUNTER_11,
|
keys=OpCodes.RESET_REBOOT_COUNTER_11,
|
||||||
info="Reset reboot counter 1 1",
|
info="Reset reboot counter 1 1",
|
||||||
)
|
)
|
||||||
|
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)
|
||||||
defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce)
|
defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce)
|
||||||
|
|
||||||
|
|
||||||
@ -155,51 +165,66 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
|
|||||||
)
|
)
|
||||||
if op_code in OpCodes.DISABLE_REBOOT_FILE_HANDLING:
|
if op_code in OpCodes.DISABLE_REBOOT_FILE_HANDLING:
|
||||||
q.add_log_cmd("Disabling reboot file handling")
|
q.add_log_cmd("Disabling reboot file handling")
|
||||||
app_data = bytearray([0])
|
user_data = bytearray([0])
|
||||||
|
q.add_pus_tc(
|
||||||
make_fsfw_action_cmd(
|
make_fsfw_action_cmd(
|
||||||
object_id=CORE_CONTROLLER_ID,
|
object_id=CORE_CONTROLLER_ID,
|
||||||
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
|
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
|
||||||
user_data=app_data,
|
user_data=user_data,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if op_code in OpCodes.ENABLE_REBOOT_FILE_HANDLING:
|
if op_code in OpCodes.ENABLE_REBOOT_FILE_HANDLING:
|
||||||
q.add_log_cmd("Enabling reboot file handling")
|
q.add_log_cmd("Enabling reboot file handling")
|
||||||
app_data = bytearray([1])
|
user_data = bytearray([1])
|
||||||
|
q.add_pus_tc(
|
||||||
make_fsfw_action_cmd(
|
make_fsfw_action_cmd(
|
||||||
object_id=CORE_CONTROLLER_ID,
|
object_id=CORE_CONTROLLER_ID,
|
||||||
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
|
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
|
||||||
user_data=app_data,
|
user_data=user_data,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if op_code in OpCodes.RESET_ALL_REBOOT_COUNTERS:
|
if op_code in OpCodes.RESET_ALL_REBOOT_COUNTERS:
|
||||||
q.add_log_cmd("Resetting all reboot counters")
|
q.add_log_cmd("Resetting all reboot counters")
|
||||||
|
q.add_pus_tc(
|
||||||
make_fsfw_action_cmd(
|
make_fsfw_action_cmd(
|
||||||
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_ALL_REBOOT_COUNTERS
|
object_id=CORE_CONTROLLER_ID,
|
||||||
|
action_id=ActionIds.RESET_REBOOT_COUNTER,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if op_code in OpCodes.RESET_REBOOT_COUNTER_00:
|
if op_code in OpCodes.RESET_REBOOT_COUNTER_00:
|
||||||
q.add_log_cmd("Resetting reboot counter 0 0")
|
reset_specific_boot_counter(q, 0, 0)
|
||||||
make_fsfw_action_cmd(
|
|
||||||
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_00
|
|
||||||
)
|
|
||||||
if op_code in OpCodes.RESET_REBOOT_COUNTER_01:
|
if op_code in OpCodes.RESET_REBOOT_COUNTER_01:
|
||||||
q.add_log_cmd("Resetting reboot counter 0 1")
|
reset_specific_boot_counter(q, 0, 1)
|
||||||
make_fsfw_action_cmd(
|
|
||||||
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_01
|
|
||||||
)
|
|
||||||
if op_code in OpCodes.RESET_REBOOT_COUNTER_10:
|
if op_code in OpCodes.RESET_REBOOT_COUNTER_10:
|
||||||
q.add_log_cmd("Resetting reboot counter 1 0")
|
reset_specific_boot_counter(q, 1, 0)
|
||||||
make_fsfw_action_cmd(
|
|
||||||
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_10
|
|
||||||
)
|
|
||||||
if op_code in OpCodes.RESET_REBOOT_COUNTER_11:
|
if op_code in OpCodes.RESET_REBOOT_COUNTER_11:
|
||||||
q.add_log_cmd("Resetting reboot counter 1 1")
|
reset_specific_boot_counter(q, 1, 1)
|
||||||
make_fsfw_action_cmd(
|
if op_code in OpCodes.OBSW_UPDATE_FROM_SD_0:
|
||||||
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_11
|
q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0)
|
||||||
)
|
q.add_pus_tc(pack_obsw_update_cmd(ActionIds.UPDATE_OBSW_FROM_SD_0))
|
||||||
|
if op_code in OpCodes.OBSW_UPDATE_FROM_SD_1:
|
||||||
|
q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_1)
|
||||||
|
q.add_pus_tc(pack_obsw_update_cmd(ActionIds.UPDATE_OBSW_FROM_SD_1))
|
||||||
|
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.GET_HK:
|
if op_code in OpCodes.GET_HK:
|
||||||
q.add_log_cmd("Requesting housekeeping set")
|
q.add_log_cmd("Requesting housekeeping set")
|
||||||
sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetIds.HK)
|
sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetIds.HK)
|
||||||
q.add_pus_tc(generate_one_hk_command(sid))
|
q.add_pus_tc(generate_one_hk_command(sid))
|
||||||
|
|
||||||
|
|
||||||
|
def reset_specific_boot_counter(q: DefaultPusQueueHelper, chip: int, copy: int):
|
||||||
|
q.add_log_cmd(f"Resetting boot counter {chip} {copy}")
|
||||||
|
q.add_pus_tc(
|
||||||
|
make_fsfw_action_cmd(
|
||||||
|
object_id=CORE_CONTROLLER_ID,
|
||||||
|
action_id=ActionIds.RESET_REBOOT_COUNTER,
|
||||||
|
user_data=bytes([chip, copy]),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def determine_reboot_params() -> (bool, Chip, Copy):
|
def determine_reboot_params() -> (bool, Chip, Copy):
|
||||||
chip_select = -1
|
chip_select = -1
|
||||||
copy_select = -1
|
copy_select = -1
|
||||||
@ -208,6 +233,10 @@ def determine_reboot_params() -> (bool, Chip, Copy):
|
|||||||
LOGGER.info("Rebooting currently running image")
|
LOGGER.info("Rebooting currently running image")
|
||||||
return True, chip_select, copy_select
|
return True, chip_select, copy_select
|
||||||
LOGGER.info("Rebooting image specified by chip and copy")
|
LOGGER.info("Rebooting image specified by chip and copy")
|
||||||
|
return False, determine_chip_and_copy()
|
||||||
|
|
||||||
|
|
||||||
|
def determine_chip_and_copy() -> (int, int):
|
||||||
while True:
|
while True:
|
||||||
chip_select = input("Chip select [0/1]: ")
|
chip_select = input("Chip select [0/1]: ")
|
||||||
if chip_select in ["0", "1"]:
|
if chip_select in ["0", "1"]:
|
||||||
@ -228,7 +257,15 @@ def determine_reboot_params() -> (bool, Chip, Copy):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
LOGGER.warning("Invalid copy select value. Try again")
|
LOGGER.warning("Invalid copy select value. Try again")
|
||||||
return False, chip_select, copy_select
|
return chip_select, copy_select
|
||||||
|
|
||||||
|
|
||||||
|
def pack_obsw_update_cmd(action_id: int) -> PusTelecommand:
|
||||||
|
chip, copy = determine_chip_and_copy()
|
||||||
|
user_data = bytes([chip, copy])
|
||||||
|
return make_fsfw_action_cmd(
|
||||||
|
object_id=CORE_CONTROLLER_ID, action_id=action_id, user_data=user_data
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def perform_reboot_cmd(
|
def perform_reboot_cmd(
|
||||||
|
Loading…
Reference in New Issue
Block a user