diff --git a/deps/tmtccmd b/deps/tmtccmd index 87a430e..acaea6d 160000 --- a/deps/tmtccmd +++ b/deps/tmtccmd @@ -1 +1 @@ -Subproject commit 87a430eb5cfea01d8265c3b327269799954c64ee +Subproject commit acaea6d9b6fe1d31283604e44c0977365c97040e diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index eb08ca4..e169ff9 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -11,7 +11,7 @@ import struct from typing import Union from spacepackets.ecss import PusTelecommand -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.util import ObjectIdU32 @@ -95,10 +95,10 @@ def pack_get_param_command( else: app_data += memory_address app_data += struct.pack("!B", parameter_size) - return generate_action_command( + return make_fsfw_action_cmd( object_id=object_id, action_id=GomspaceDeviceActionIds.PARAM_GET, - app_data=app_data, + user_data=app_data, ) @@ -135,8 +135,8 @@ def pack_set_param_command( app_data.append(byte_two) app_data.append(byte_three) app_data.append(byte_four) - return generate_action_command( - object_id=object_id, action_id=action_id, app_data=app_data, ssc=ssc + return make_fsfw_action_cmd( + object_id=object_id, action_id=action_id, user_data=app_data, ssc=ssc ) @@ -148,10 +148,10 @@ def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand @note The ping request sends the specified data to a gompsace device. These data are simply copied by the device and then sent back. """ - return generate_action_command( + return make_fsfw_action_cmd( object_id=object_id.as_bytes, action_id=GomspaceDeviceActionIds.PING, - app_data=data, + user_data=data, ) @@ -159,7 +159,7 @@ def pack_gnd_wdt_reset_command(object_id: ObjectIdU32) -> PusTelecommand: """ " Function to generate the command to reset the watchdog of a gomspace device. @param object_id Object Id of the gomspace device handler. """ - return generate_action_command( + return make_fsfw_action_cmd( object_id=object_id.as_bytes, action_id=GomspaceDeviceActionIds.WDT_RESET ) @@ -168,7 +168,7 @@ def pack_reboot_command(object_id: ObjectIdU32) -> PusTelecommand: """Function to generate the command which triggers a reboot of a gomspace device @param object_id The object id of the gomspace device handler. """ - return generate_action_command( + return make_fsfw_action_cmd( object_id=object_id.as_bytes, action_id=GomspaceDeviceActionIds.REBOOT ) @@ -178,6 +178,6 @@ def pack_request_full_hk_table_command(object_id: ObjectIdU32) -> PusTelecommand device. @param object_id The object id of the gomspace device handler. """ - return generate_action_command( + return make_fsfw_action_cmd( object_id=object_id.as_bytes, action_id=GomspaceDeviceActionIds.REQUEST_HK_TABLE ) diff --git a/pus_tc/devs/acu.py b/pus_tc/devs/acu.py index 9f846c9..198edcc 100644 --- a/pus_tc/devs/acu.py +++ b/pus_tc/devs/acu.py @@ -20,7 +20,7 @@ from gomspace.gomspace_common import GomspaceOpCodes from gomspace.gomspace_common import GsInfo as GsInfo from config.object_ids import ACU_HANDLER_ID from pus_tc.devs.p60dock import P60DockConfigTable -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.util import ObjectIdU32 @@ -85,7 +85,7 @@ def pack_acu_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd("ACU: Print channel stats") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=object_id.as_bytes, action_id=gs.GomspaceDeviceActionIds.PRINT_SWITCH_V_I, ) diff --git a/pus_tc/devs/bpx_batt.py b/pus_tc/devs/bpx_batt.py index b331b7a..108b02a 100644 --- a/pus_tc/devs/bpx_batt.py +++ b/pus_tc/devs/bpx_batt.py @@ -3,7 +3,7 @@ from config.object_ids import BPX_HANDLER_ID from tmtccmd import DefaultProcedureInfo, TcHandlerBase from tmtccmd.tc import DefaultPusQueueHelper, service_provider from tmtccmd.tc.decorator import ServiceProviderParams -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid @@ -38,14 +38,14 @@ def pack_bpx_commands(p: ServiceProviderParams): if op_code in BpxOpCodes.RST_BOOT_CNT: q.add_log_cmd("Resetting reboot counters") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS ) ) if op_code in BpxOpCodes.REQUEST_CFG: q.add_log_cmd("Requesting configuration struct") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG ) ) @@ -56,7 +56,7 @@ def pack_bpx_commands(p: ServiceProviderParams): if op_code in BpxOpCodes.REBOOT: q.add_log_cmd("Rebooting BPX battery") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT ) ) diff --git a/pus_tc/devs/heater.py b/pus_tc/devs/heater.py index 5d00185..b7e9cde 100644 --- a/pus_tc/devs/heater.py +++ b/pus_tc/devs/heater.py @@ -16,7 +16,7 @@ from tmtccmd.tc.pus_201_fsfw_health import ( FsfwHealth, Subservices, ) -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from spacepackets.ecss.tc import PusTelecommand @@ -200,6 +200,6 @@ def pack_switch_heater_command( command.append(switch_nr) command.append(switch_action) command.append(COMMAND_SOURCE_PARAM_EXTERNAL) - return generate_action_command( - object_id=object_id, action_id=ActionIds.SWITCH_HEATER, app_data=command + return make_fsfw_action_cmd( + object_id=object_id, action_id=ActionIds.SWITCH_HEATER, user_data=command ) diff --git a/pus_tc/devs/p60dock.py b/pus_tc/devs/p60dock.py index 5783f06..e460862 100644 --- a/pus_tc/devs/p60dock.py +++ b/pus_tc/devs/p60dock.py @@ -22,7 +22,7 @@ from gomspace.gomspace_common import ( SetIds, ) from config.object_ids import P60_DOCK_HANDLER -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.util import ObjectIdU32 @@ -150,14 +150,14 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd("P60 Dock: Print Switches, Voltages, Currents") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) ) if op_code in GomspaceOpCodes.PRINT_LATCHUPS: q.add_log_cmd("P60 Dock: Print Latchups") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS ) ) diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index 4662b0e..ed67e2c 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -42,14 +42,14 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd("PDU1: Print Switches, Voltages, Currents") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) ) if op_code in GomspaceOpCodes.PRINT_LATCHUPS: q.add_log_cmd("PDU1: Print Latchups") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS ) ) diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index 6ccd49d..ba3519e 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -53,14 +53,14 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd(f"PDU2: {GsInfo.PRINT_SWITCH_V_I}") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) ) if op_code in GomspaceOpCodes.PRINT_LATCHUPS: q.add_log_cmd("PDU2: Print Latchups") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS ) ) diff --git a/pus_tc/devs/scex.py b/pus_tc/devs/scex.py index f02e30c..355beec 100644 --- a/pus_tc/devs/scex.py +++ b/pus_tc/devs/scex.py @@ -6,7 +6,7 @@ from tmtccmd import DefaultProcedureInfo, TcHandlerBase from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tc import DefaultPusQueueHelper, service_provider from tmtccmd.tc.decorator import ServiceProviderParams -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper from config.object_ids import SCEX_HANDLER_ID @@ -71,25 +71,23 @@ def pack_scex_cmds(p: ServiceProviderParams): if op_code in OpCodes.PING: q.add_log_cmd(Info.PING) app_data = bytes([0]) - q.add_pus_tc(generate_action_command(SCEX_HANDLER_ID, ActionIds.PING, app_data)) + q.add_pus_tc(make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.PING, app_data)) if op_code in OpCodes.ION_CMD: q.add_log_cmd(Info.ION_CMD) app_data = bytes([0]) - q.add_pus_tc( - generate_action_command(SCEX_HANDLER_ID, ActionIds.ION_CMD, app_data) - ) + q.add_pus_tc(make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.ION_CMD, app_data)) if op_code in OpCodes.TEMP_CMD: q.add_log_cmd(Info.TEMP_CMD) app_data = bytes([0]) q.add_pus_tc( - generate_action_command(SCEX_HANDLER_ID, ActionIds.TEMP_CMD, app_data) + make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.TEMP_CMD, app_data) ) if op_code in OpCodes.EXP_STATUS_CMD: q.add_log_cmd(Info.EXP_STATUS_CMD) app_data = bytes([0]) q.add_pus_tc( - generate_action_command(SCEX_HANDLER_ID, ActionIds.EXP_STATUS_CMD, app_data) + make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.EXP_STATUS_CMD, app_data) ) # one cell @@ -137,7 +135,7 @@ def pack_scex_cmds(p: ServiceProviderParams): app_data.append(dac_weight3[cn]) q.add_pus_tc( - generate_action_command(SCEX_HANDLER_ID, ActionIds.ONE_CELLS_CMD, app_data) + make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.ONE_CELLS_CMD, app_data) ) if op_code in OpCodes.ALL_CELLS_CMD: @@ -169,13 +167,13 @@ def pack_scex_cmds(p: ServiceProviderParams): app_data.append(dac_weight3[cn]) q.add_pus_tc( - generate_action_command(SCEX_HANDLER_ID, ActionIds.ALL_CELLS_CMD, app_data) + make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.ALL_CELLS_CMD, app_data) ) if op_code in OpCodes.FRAM: q.add_log_cmd(Info.FRAM) app_data = bytes([0]) - q.add_pus_tc(generate_action_command(SCEX_HANDLER_ID, ActionIds.FRAM, app_data)) + q.add_pus_tc(make_fsfw_action_cmd(SCEX_HANDLER_ID, ActionIds.FRAM, app_data)) def append_16_bit_val(packet: bytearray, val: int): diff --git a/pus_tc/system/core.py b/pus_tc/system/core.py index 112fae7..ff3423a 100644 --- a/pus_tc/system/core.py +++ b/pus_tc/system/core.py @@ -4,7 +4,7 @@ from config.definitions import CustomServiceList from tmtccmd.config import TmtcDefinitionWrapper from tmtccmd.tc import DefaultPusQueueHelper -from tmtccmd.tc.pus_8_funccmd import generate_action_command +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.logging import get_console_logger from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider @@ -125,7 +125,7 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str): if op_code in OpCodes.REBOOT_FULL: q.add_log_cmd(f"Core Command: {Info.REBOOT_FULL}") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.FULL_REBOOT ) ) @@ -156,42 +156,42 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str): if op_code in OpCodes.DISABLE_REBOOT_FILE_HANDLING: q.add_log_cmd("Disabling reboot file handling") app_data = bytearray([0]) - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING, - app_data=app_data, + user_data=app_data, ) if op_code in OpCodes.ENABLE_REBOOT_FILE_HANDLING: q.add_log_cmd("Enabling reboot file handling") app_data = bytearray([1]) - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING, - app_data=app_data, + user_data=app_data, ) if op_code in OpCodes.RESET_ALL_REBOOT_COUNTERS: q.add_log_cmd("Resetting all reboot counters") - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_ALL_REBOOT_COUNTERS ) if op_code in OpCodes.RESET_REBOOT_COUNTER_00: q.add_log_cmd("Resetting reboot counter 0 0") - generate_action_command( + 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: q.add_log_cmd("Resetting reboot counter 0 1") - generate_action_command( + 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: q.add_log_cmd("Resetting reboot counter 1 0") - generate_action_command( + 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: q.add_log_cmd("Resetting reboot counter 1 1") - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_11 ) if op_code in OpCodes.GET_HK: @@ -247,10 +247,10 @@ def perform_reboot_cmd( tc_data.append(copy) q.add_log_cmd(f"Packing reboot command for chip {chip} and copy {copy}") q.add_pus_tc( - generate_action_command( + make_fsfw_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionIds.XSC_REBOOT, - app_data=tc_data, + user_data=tc_data, ssc=0, ) ) diff --git a/pus_tm/event_handler.py b/pus_tm/event_handler.py index 0b7adce..7ec4a7c 100644 --- a/pus_tm/event_handler.py +++ b/pus_tm/event_handler.py @@ -46,9 +46,12 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter): generic_event_string = ( f"Object {obj_name} generated Event {tm.event_id} | {info.name}" ) - if info.name == "SUPV_UPDATE_PROGRESS": + if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED": additional_event_info = f"Additional info: {info.info}" - context = f"Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} | Bytes Written: {tm.param_2}" + context = ( + f"Progress Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} " + f"| Bytes Written: {tm.param_2}" + ) pw.dlog(additional_event_info) pw.dlog(context) else: diff --git a/tmtc/ploc_supervisor.py b/tmtc/ploc_supervisor.py index 24b4e13..1d9770a 100644 --- a/tmtc/ploc_supervisor.py +++ b/tmtc/ploc_supervisor.py @@ -19,6 +19,7 @@ from tmtccmd.logging import get_console_logger from tmtccmd.tc import service_provider from tmtccmd.tc.decorator import ServiceProviderParams from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes +from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter from utility.input_helper import InputHelper @@ -106,6 +107,7 @@ class SupvActionIds: RESET_PL = 58 ENABLE_NVMS = 59 CONTINUE_UPDATE = 60 + MEM_CHECK = 61 class SetIds: @@ -127,6 +129,7 @@ class OpCodes: STOP_MPSOC = ["6", "mpsoc-stop"] START_UPDATE = ["42", "start-update"] PERFORM_UPDATE = ["update"] + MEM_CHECK = ["mem-check"] class Info(str, enum.Enum): @@ -136,6 +139,7 @@ class Info(str, enum.Enum): NML = "Switch Normal" HK_TO_OBC = "Request HK from PLOC SUPV" REQUEST_HK = "Request HK set from PLOC Handler" + MEM_CHECK = "Memory Check" @tmtc_definitions_provider @@ -187,6 +191,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add("56", "PLOC Supervisor: Reset PL") oce.add("57", "PLOC Supervisor: Enable NVMs") oce.add("58", "PLOC Supervisor: Continue update") + oce.add(OpCodes.MEM_CHECK, Info.MEM_CHECK) defs.add_service(CustomServiceList.PLOC_SUPV.value, "PLOC Supervisor", oce) @@ -424,6 +429,22 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): q.add_log_cmd("PLOC Supervisor: Continue update") command = object_id.as_bytes + struct.pack("!I", SupvActionIds.CONTINUE_UPDATE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) + if op_code in OpCodes.MEM_CHECK: + custom_data = bytearray() + memory_id = int(input("Specify memory ID: ")) + start_address = int(input("Specify start address: 0x"), 16) + check_size = int(input("Specify check size: 0x")) + custom_data.extend(struct.pack("!B", memory_id)) + custom_data.extend(struct.pack("!I", start_address)) + custom_data.extend(struct.pack("!I", check_size)) + q.add_log_cmd( + f"{prefix}: {Info.MEM_CHECK} for memory ID {memory_id} at start " + f"address {start_address} with check size {check_size}" + ) + command = make_fsfw_action_cmd( + object_id.as_bytes, SupvActionIds.MEM_CHECK, custom_data + ) + q.add_pus_tc(command) def pack_sel_boot_image_cmd(