small refactoring

This commit is contained in:
Robin Müller 2023-01-11 14:23:03 +01:00
parent d48e86f5fe
commit 7d2c639f01
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
1 changed files with 21 additions and 15 deletions

View File

@ -144,7 +144,7 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
def pack_core_commands(q: DefaultPusQueueHelper, op_code: str): def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
if op_code in OpCodes.REBOOT_XSC: if op_code in OpCodes.REBOOT_XSC:
reboot_self, chip_select, copy_select = determine_reboot_params() reboot_self, chip_select, copy_select = determine_reboot_params()
perform_reboot_cmd( add_xsc_reboot_cmd(
q=q, q=q,
reboot_self=reboot_self, reboot_self=reboot_self,
chip=chip_select, chip=chip_select,
@ -158,24 +158,24 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
) )
) )
if op_code in OpCodes.XSC_REBOOT_SELF: if op_code in OpCodes.XSC_REBOOT_SELF:
perform_reboot_cmd(q=q, reboot_self=True) add_xsc_reboot_cmd(q=q, reboot_self=True)
if op_code in OpCodes.XSC_REBOOT_0_0: if op_code in OpCodes.XSC_REBOOT_0_0:
perform_reboot_cmd( add_xsc_reboot_cmd(
q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM
) )
if op_code in OpCodes.XSC_REBOOT_0_1: if op_code in OpCodes.XSC_REBOOT_0_1:
perform_reboot_cmd( add_xsc_reboot_cmd(
q=q, q=q,
reboot_self=False, reboot_self=False,
chip=Chip.CHIP_0, chip=Chip.CHIP_0,
copy=Copy.COPY_1_GOLD, copy=Copy.COPY_1_GOLD,
) )
if op_code in OpCodes.XSC_REBOOT_1_0: if op_code in OpCodes.XSC_REBOOT_1_0:
perform_reboot_cmd( add_xsc_reboot_cmd(
q=q, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_0_NOM q=q, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_0_NOM
) )
if op_code in OpCodes.XSC_REBOOT_1_1: if op_code in OpCodes.XSC_REBOOT_1_1:
perform_reboot_cmd( add_xsc_reboot_cmd(
q=q, q=q,
reboot_self=False, reboot_self=False,
chip=Chip.CHIP_1, chip=Chip.CHIP_1,
@ -314,27 +314,33 @@ def pack_obsw_update_cmd(action_id: int) -> PusTelecommand:
) )
def perform_reboot_cmd( def add_xsc_reboot_cmd(
q: DefaultPusQueueHelper, q: DefaultPusQueueHelper,
reboot_self: bool, reboot_self: bool,
chip: Chip = Chip.NONE, chip: Chip = Chip.NONE,
copy: Copy = Copy.NONE, copy: Copy = Copy.NONE,
): ):
tc_data = bytearray()
if reboot_self: if reboot_self:
q.add_log_cmd("Packing reboot command for current image") q.add_log_cmd("Packing reboot command for current image")
else:
q.add_log_cmd(f"Packing reboot command for chip {chip} and copy {copy}")
q.add_pus_tc(create_xsc_reboot_cmds(reboot_self, chip, copy))
def create_xsc_reboot_cmds(
reboot_self: bool,
chip: Chip = Chip.NONE,
copy: Copy = Copy.NONE,
) -> PusTelecommand:
tc_data = bytearray()
if reboot_self:
tc_data.append(True) tc_data.append(True)
else: else:
tc_data.append(False) tc_data.append(False)
tc_data.append(chip) tc_data.append(chip)
tc_data.append(copy) tc_data.append(copy)
q.add_log_cmd(f"Packing reboot command for chip {chip} and copy {copy}") return make_fsfw_action_cmd(
q.add_pus_tc( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.XSC_REBOOT, user_data=tc_data
make_fsfw_action_cmd(
object_id=CORE_CONTROLLER_ID,
action_id=ActionIds.XSC_REBOOT,
user_data=tc_data,
)
) )