From 9ed2593a54fecbea89dd812bbe87d4122a30bf83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 21 Aug 2022 00:22:41 +0200 Subject: [PATCH] update ploc supv update cmd --- tmtc/ploc_supervisor.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tmtc/ploc_supervisor.py b/tmtc/ploc_supervisor.py index f6f9ab1..24b4e13 100644 --- a/tmtc/ploc_supervisor.py +++ b/tmtc/ploc_supervisor.py @@ -125,6 +125,8 @@ class OpCodes: REQUEST_HK = ["4", "req-hk"] START_MPSOC = ["5", "mpsoc-start"] STOP_MPSOC = ["6", "mpsoc-stop"] + START_UPDATE = ["42", "start-update"] + PERFORM_UPDATE = ["update"] class Info(str, enum.Enum): @@ -170,7 +172,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add("38", "PLOC Supervisor: Factory reset clear all") oce.add("39", "PLOC Supervisor: Factory reset clear mirror entries") oce.add("40", "PLOC Supervisor: Factory reset clear circular entries") - oce.add("42", "PLOC Supervisor: Perform update") + oce.add(OpCodes.PERFORM_UPDATE, "PLOC Supervisor: Perform update") oce.add("43", "PLOC Supervisor: Terminate supervisor process") oce.add("44", "PLOC Supervisor: Start MPSoC quiet") oce.add("45", "PLOC Supervisor: Set shutdown timeout") @@ -345,7 +347,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): "!I", SupvActionIds.FACTORY_RESET_CLEAR_CIRCULAR ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "42": + if op_code in OpCodes.PERFORM_UPDATE: q.add_log_cmd("PLOC Supervisor: Perform update") command = pack_update_command(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -607,6 +609,14 @@ def pack_update_command(object_id: bytes) -> bytearray: memory_id = int(input("Specify memory ID: ")) start_address = int(input("Specify start address: 0x"), 16) update_file = get_update_file() + init_bytes_written = input("Specify bytes to start from [0 default]: ") + if init_bytes_written == "": + init_bytes_written = 0 + init_bytes_written = int(init_bytes_written) + init_seq_count = input("Specify initial sequence count [1 default]: ") + if init_seq_count == "": + init_seq_count = 0 + init_seq_count = int(init_seq_count) command += object_id command += struct.pack("!I", SupvActionIds.PERFORM_UPDATE) command += bytearray(update_file, "utf-8") @@ -614,6 +624,8 @@ def pack_update_command(object_id: bytes) -> bytearray: command += struct.pack("!B", 0) command += struct.pack("!B", memory_id) command += struct.pack("!I", start_address) + command.extend(struct.pack("!I", init_bytes_written)) + command.extend(struct.pack("!H", init_seq_count)) return bytearray(command)