From a7326b95c49d59d0fc97a7befae7e5bab977a41c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 10 Jan 2023 09:56:18 +0100 Subject: [PATCH] improve ploc mpsoc commanding --- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 41 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index b0e0121..3e1710b 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -23,6 +23,7 @@ from tmtccmd.tc.decorator import ServiceProviderParams from eive_tmtc.utility.input_helper import InputHelper from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes + LOGGER = get_console_logger() MANUAL_INPUT = "1" @@ -70,6 +71,10 @@ class OpCodes: NORMAL = ["normal"] VERIFY_BOOT = ["verify_boot"] MODE_REPLAY = ["mode_replay"] + MODE_IDLE = ["mode_idle"] + REPLAY_WRITE_SEQ = ["replay_write"] + DOWNLINK_PWR_ON = ["downlink_pwr_on"] + REPLAY_START = ["replay_start"] class Info: @@ -78,6 +83,10 @@ class Info: NORMAL = "Normal" VERIFY_BOOT = "Verify boot by reading 0xdeadbeef from DEADBEEF address" MODE_REPLAY = "Switch to REPLAY mode" + MODE_IDLE = "Switch to IDLE mode" + REPLAY_WRITE_SEQ = "Replay write sequence" + DOWNLINK_PWR_ON = "Downlink Power On" + REPLAY_START = "Replay Start" class MemAddresses(enum.IntEnum): @@ -99,15 +108,15 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): oce.add("4", "Ploc MPSoC: Memory read") oce.add("5", "Ploc MPSoC: Flash write") oce.add("6", "Ploc MPSoC: Flash delete") - oce.add("7", "Ploc MPSoC: Replay start") + oce.add(OpCodes.REPLAY_START, Info.REPLAY_START) oce.add("8", "Ploc MPSoC: Replay stop") - oce.add("9", "Ploc MPSoC: Downlink pwr on") + oce.add(OpCodes.DOWNLINK_PWR_ON, Info.DOWNLINK_PWR_ON) oce.add("10", "Ploc MPSoC: Downlink pwr off") - oce.add("11", "Ploc MPSoC: Replay write sequence") + oce.add(OpCodes.REPLAY_WRITE_SEQ, Info.REPLAY_WRITE_SEQ) oce.add("12", "Ploc MPSoC: OBSW reset sequence count") oce.add(OpCodes.VERIFY_BOOT, "Ploc MPSoC: Read DEADBEEF address") oce.add(OpCodes.MODE_REPLAY, Info.MODE_REPLAY) - oce.add("15", "Ploc MPSoC: Mode IDLE") + oce.add(OpCodes.MODE_IDLE, Info.MODE_IDLE) oce.add("16", "Ploc MPSoC: Tc cam command send") oce.add("17", "Ploc MPSoC: Set UART TX tristate") oce.add("18", "Ploc MPSoC: Relesase UART TX") @@ -118,22 +127,22 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): def pack_ploc_mpsoc_commands(p: ServiceProviderParams): object_id = get_object_ids().get(PLOC_MPSOC_ID) q = p.queue_helper - prefix = "PLOC SUPV:" + prefix = "PLOC MPSoC" op_code = p.op_code q.add_log_cmd( f"Generate command for PLOC MPSoC with object id: {object_id.as_hex_string}" ) obyt = object_id.as_bytes if op_code in OpCodes.OFF: - q.add_log_cmd(f"{prefix} {Info.OFF}") + q.add_log_cmd(f"{prefix}: {Info.OFF}") command = pack_mode_data(obyt, Modes.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) if op_code in OpCodes.ON: - q.add_log_cmd(f"{prefix} {Info.ON}") + q.add_log_cmd(f"{prefix}: {Info.ON}") data = pack_mode_data(obyt, Modes.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) if op_code in OpCodes.NORMAL: - q.add_log_cmd(f"{prefix} {Info.NORMAL}") + q.add_log_cmd(f"{prefix}: {Info.NORMAL}") data = pack_mode_data(object_id.as_bytes, Modes.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) if op_code == "3": @@ -160,24 +169,24 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams): q.add_log_cmd("PLOC MPSoC: Flash delete") data = prepare_flash_delete_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "7": - q.add_log_cmd("PLOC MPSoC: Replay start") + if op_code in OpCodes.REPLAY_START: + q.add_log_cmd(f"{prefix}: {Info.REPLAY_START}") data = prepare_replay_start_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "8": q.add_log_cmd("PLOC MPSoC: Replay stop") data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_REPLAY_STOP) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "9": - q.add_log_cmd("PLOC MPSoC: Downlink pwr on") + if op_code in OpCodes.DOWNLINK_PWR_ON: + q.add_log_cmd(f"{prefix}: {OpCodes.DOWNLINK_PWR_ON}") data = prepare_downlink_pwr_on_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "10": q.add_log_cmd("PLOC MPSoC: Downlink pwr off") data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_DOWNLINK_PWR_OFF) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "11": - q.add_log_cmd("PLOC MPSoC: Replay write sequence") + if op_code in OpCodes.REPLAY_WRITE_SEQ: + q.add_log_cmd(f"{prefix}: {Info.REPLAY_WRITE_SEQ}") data = prepare_replay_write_sequence_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "12": @@ -194,11 +203,11 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams): + struct.pack("!H", num_words) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "14": + if op_code in OpCodes.MODE_REPLAY: q.add_log_cmd("PLOC MPSoC: Tc mode replay") data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_MODE_REPLAY) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "15": + if op_code in OpCodes.MODE_IDLE: q.add_log_cmd("PLOC MPSoC: Tc mode idle") data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_MODE_IDLE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))