add cmd to set max reboot watchdog count #210

Merged
muellerr merged 2 commits from rwd-improvements into main 2023-07-06 19:03:06 +02:00

View File

@ -89,14 +89,14 @@ class OpCode:
SWITCH_TO_SD_1 = ["switch_to_sd_1"]
SWITCH_TO_BOTH_SD_CARDS = ["switch_to_both_sd_cards"]
READ_REBOOT_MECHANISM_INFO = "rbh_info"
ENABLE_REBOOT_FILE_HANDLING = "rbh_off"
DISABLE_REBOOT_FILE_HANDLING = "rbh_on"
RESET_ALL_REBOOT_COUNTERS = "rbh_reset_a"
RESET_REBOOT_COUNTER_00 = "rbh_reset_00"
RESET_REBOOT_COUNTER_01 = "rbh_reset_01"
RESET_REBOOT_COUNTER_10 = "rbh_reset_10"
RESET_REBOOT_COUNTER_11 = "rbh_reset_11"
SET_MAX_REBOOT_CNT = ["rbh_max_cnt"]
ENABLE_REBOOT_FILE_HANDLING = "rwd_on"
DISABLE_REBOOT_FILE_HANDLING = "rwd_off"
RESET_ALL_REBOOT_COUNTERS = "rwd_reset_a"
RWD_RESET_REBOOT_COUNTER_00 = "rwd_reset_00"
RWD_RESET_REBOOT_COUNTER_01 = "rwd_reset_01"
RWD_RESET_REBOOT_COUNTER_10 = "rwd_reset_10"
RWD_RESET_REBOOT_COUNTER_11 = "rwd_reset_11"
RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt"
class Info:
@ -188,21 +188,25 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
info="Reset all reboot counters",
)
oce.add(
keys=OpCode.RESET_REBOOT_COUNTER_00,
keys=OpCode.RWD_RESET_REBOOT_COUNTER_00,
info="Reset reboot counter 0 0",
)
oce.add(
keys=OpCode.RESET_REBOOT_COUNTER_01,
keys=OpCode.RWD_RESET_REBOOT_COUNTER_01,
info="Reset reboot counter 0 1",
)
oce.add(
keys=OpCode.RESET_REBOOT_COUNTER_10,
keys=OpCode.RWD_RESET_REBOOT_COUNTER_10,
info="Reset reboot counter 1 0",
)
oce.add(
keys=OpCode.RESET_REBOOT_COUNTER_11,
keys=OpCode.RWD_RESET_REBOOT_COUNTER_11,
info="Reset reboot counter 1 1",
)
oce.add(
keys=OpCode.RWD_SET_MAX_REBOOT_CNT,
info="Reset max reboot count for reboot watchdog",
)
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.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
@ -336,14 +340,25 @@ def pack_core_commands( # noqa C901
action_id=ActionId.RESET_REBOOT_COUNTER,
)
)
elif op_code == OpCode.RESET_REBOOT_COUNTER_00:
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_00:
reset_specific_boot_counter(q, 0, 0)
elif op_code == OpCode.RESET_REBOOT_COUNTER_01:
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_01:
reset_specific_boot_counter(q, 0, 1)
elif op_code == OpCode.RESET_REBOOT_COUNTER_10:
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_10:
reset_specific_boot_counter(q, 1, 0)
elif op_code == OpCode.RESET_REBOOT_COUNTER_11:
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_11:
reset_specific_boot_counter(q, 1, 1)
elif op_code == OpCode.RWD_SET_MAX_REBOOT_CNT:
max_count = int(input("Set new maximum reboot threshold [1, 50]: "))
if max_count < 1 or max_count > 50:
raise ValueError("Invalid value, must be in range 1 to 50")
q.add_pus_tc(
create_action_cmd(
CORE_CONTROLLER_ID,
ActionId.SET_MAX_REBOOT_CNT,
user_data=bytes([max_count]),
)
)
elif op_code in OpCode.OBSW_UPDATE_FROM_SD_0:
q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0)
q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_0))