From 31d51e3660abd77e3de619431ec99925010e8a7a Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 13:56:50 +0100 Subject: [PATCH 01/10] added commands for missing submodes --- eive_tmtc/tmtc/acs/acs_ctrl.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index ce39d4d..0fa6c5e 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -55,6 +55,10 @@ class OpCodes: SAFE = ["normal_safe"] DTBL = ["normal_detumble"] IDLE = ["normal_idle"] + NADIR = ["normal_nadir"] + TARGET = ["normal_target"] + GS = ["normal_gs"] + INERTIAL = ["normal_inertial"] REQUEST_RAW_MGM_HK = ["0", "mgm_raw_hk"] ENABLE_RAW_MGM_HK = ["1", "mgm_raw_enable_hk"] DISABLE_RAW_MGM_HK = ["2", "mgm_raw_disable_hk"] @@ -89,9 +93,13 @@ class OpCodes: class Info: OFF = "Switch ACS CTRL off" - SAFE = "Switch ACS CTRL normal safe" - DTBL = "Switch ACS CTRL normal detumble" - IDLE = "Switch ACS CTRL normal idle" + SAFE = "Switch ACS CTRL normal - safe" + DTBL = "Switch ACS CTRL normal - detumble" + IDLE = "Switch ACS CTRL normal - idle" + NADIR = "Switch ACS CTRL normal - pointing nadir" + TARGET = "Switch ACS CTRL normal - pointing target" + GS = "Switch ACS CTRL normal - pointing target groundstation" + INERTIAL = "Switch ACS CTRL normal - pointing inertial" REQUEST_RAW_MGM_HK = "Request Raw MGM HK once" ENABLE_RAW_MGM_HK = "Enable Raw MGM HK data generation" DISABLE_RAW_MGM_HK = "Disable Raw MGM HK data generation" @@ -143,6 +151,10 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.SAFE, info=Info.SAFE) oce.add(keys=OpCodes.DTBL, info=Info.DTBL) oce.add(keys=OpCodes.IDLE, info=Info.IDLE) + oce.add(keys=OpCodes.NADIR, info=Info.NADIR) + oce.add(keys=OpCodes.TARGET, info=Info.TARGET) + oce.add(keys=OpCodes.GS, info=Info.GS) + oce.add(keys=OpCodes.INERTIAL, info=Info.INERTIAL) oce.add(keys=OpCodes.REQUEST_RAW_MGM_HK, info=Info.REQUEST_RAW_MGM_HK) oce.add(keys=OpCodes.ENABLE_RAW_MGM_HK, info=Info.ENABLE_RAW_MGM_HK) oce.add(keys=OpCodes.DISABLE_RAW_MGM_HK, info=Info.DISABLE_RAW_MGM_HK) @@ -194,6 +206,18 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.IDLE: q.add_log_cmd(f"{Info.IDLE}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.IDLE)) + elif op_code in OpCodes.NADIR: + q.add_log_cmd(f"{Info.NADIR}") + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_NADIR)) + elif op_code in OpCodes.TARGET: + q.add_log_cmd(f"{Info.TARGET}") + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET)) + elif op_code in OpCodes.GS: + q.add_log_cmd(f"{Info.GS}") + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET_GS)) + elif op_code in OpCodes.INERTIAL: + q.add_log_cmd(f"{Info.INERTIAL}") + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_INERTIAL)) elif op_code in OpCodes.REQUEST_RAW_MGM_HK: q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) q.add_pus_tc( From 09dbc6b14d26173814edf35b72c06dddf44b238f Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 14:01:39 +0100 Subject: [PATCH 02/10] updated handle_mekf_data --- eive_tmtc/tmtc/acs/acs_ctrl.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 0fa6c5e..be8ad18 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -732,8 +732,10 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): pw.dlog("Received CTRL Values Set") fmt_quat = "!dddd" fmt_scalar = "!d" + fmt_vec = "!ddd" inc_len_quat = struct.calcsize(fmt_quat) inc_len_scalar = struct.calcsize(fmt_scalar) + inc_len_vec = struct.calcsize(fmt_vec) if len(hk_data) < 2 * inc_len_quat + inc_len_scalar: pw.dlog("Received HK set too small") return @@ -759,10 +761,18 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): ) ] current_idx += inc_len_scalar + tgt_rot = [ + f"{val:8.3f}" + for val in struct.unpack( + fmt_vec, hk_data[current_idx : current_idx + inc_len_vec] + ) + ] + current_idx += inc_len_vec pw.dlog(f"Control Values Target Quaternion: {tgt_quat}") pw.dlog(f"Control Values Error Quaternion: {err_quat}") pw.dlog(f"Control Values Error Angle: {err_ang} [rad]") - pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=3) + pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [rad/s]") + pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=4) def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes): From bc9f13f296aed7bf055f1caa67dd233d575782f6 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 14:53:09 +0100 Subject: [PATCH 03/10] diag datasets and mekf update --- eive_tmtc/tmtc/acs/acs_ctrl.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index be8ad18..934ccbf 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -297,7 +297,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.REQUEST_RAW_GYR_HK: q.add_log_cmd(Info.REQUEST_RAW_GYR_HK) q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET)) + create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET)) ) elif op_code in OpCodes.ENABLE_RAW_GYR_HK: q.add_log_cmd(Info.ENABLE_RAW_GYR_HK) @@ -323,7 +323,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.ENABLE_PROC_GYR_HK: q.add_log_cmd(Info.ENABLE_PROC_GYR_HK) cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET), 2.0 + True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET), 2.0 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) @@ -331,7 +331,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): q.add_log_cmd(Info.DISABLE_PROC_GYR_HK) q.add_pus_tc( disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) + True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) ) ) elif op_code in OpCodes.REQUEST_PROC_GPS_HK: @@ -355,7 +355,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): ) elif op_code in OpCodes.REQUEST_MEKF_HK: q.add_log_cmd(Info.REQUEST_MEKF_HK) - q.add_pus_tc(generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MEKF_DATA))) + q.add_pus_tc(create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.MEKF_DATA))) elif op_code in OpCodes.ENABLE_MEKF_HK: q.add_log_cmd(Info.ENABLE_MEKF_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -708,14 +708,18 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): + mekfStatus = {0 : "UNINITIALIZED", 1: "NO_GYR_DATA", 2: "NO_MODEL_VECTORS", 3: "NO_SUS_MGM_STR_DATA", + 4: "COVARIANCE_INVERSION_FAILED", 10: "INITIALIZED", 11: "RUNNING"} pw.dlog("Received MEKF Set") fmt_quat = "!dddd" fmt_str_4 = "[{:8.3f}, {:8.3f}, {:8.3f}, {:8.3f}]" fmt_str_3 = "[{:8.3f}, {:8.3f}, {:8.3f}]" fmt_vec = "!ddd" + fmt_sts = "!B" inc_len_quat = struct.calcsize(fmt_quat) inc_len_vec = struct.calcsize(fmt_vec) - if len(hk_data) < inc_len_quat + inc_len_vec: + inc_len_sts = struct.calcsize(fmt_sts) + if len(hk_data) < inc_len_quat + inc_len_vec + inc_len_sts: pw.dlog("Received HK set too small") return current_idx = 0 @@ -723,9 +727,12 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): current_idx += inc_len_quat rate = struct.unpack(fmt_vec, hk_data[current_idx : current_idx + inc_len_vec]) current_idx += inc_len_vec + status = struct.unpack(fmt_sts, hk_data[current_idx : current_idx + inc_len_sts])[0] + current_idx += inc_len_sts + pw.dlog(f"{'MEKF Status'.ljust(25)}: {mekfStatus[status]}") pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}") pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rate)}") - pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=2) + pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=3) def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): @@ -736,7 +743,7 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): inc_len_quat = struct.calcsize(fmt_quat) inc_len_scalar = struct.calcsize(fmt_scalar) inc_len_vec = struct.calcsize(fmt_vec) - if len(hk_data) < 2 * inc_len_quat + inc_len_scalar: + if len(hk_data) < 2 * inc_len_quat + inc_len_scalar + inc_len_vec: pw.dlog("Received HK set too small") return current_idx = 0 From 23aeb8bcf92143b86d96acd0b8acfe085d6eb439 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 15:06:54 +0100 Subject: [PATCH 04/10] added action commands --- eive_tmtc/tmtc/acs/acs_ctrl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 934ccbf..16e398a 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -23,6 +23,7 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( disable_periodic_hk_command, create_request_one_diag_command, ) +from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter @@ -49,6 +50,9 @@ class Submode(enum.IntEnum): PTG_TARGET_GS = 15 PTG_INERTIAL = 16 +class ActionId(enum.IntEnum): + SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL = 0 + RESET_MEKF = 1 class OpCodes: OFF = ["off"] @@ -59,6 +63,8 @@ class OpCodes: TARGET = ["normal_target"] GS = ["normal_gs"] INERTIAL = ["normal_inertial"] + SAFE_PTG = ["confirm_deployment"] + RESET_MEKF = ["reset_mekf"] REQUEST_RAW_MGM_HK = ["0", "mgm_raw_hk"] ENABLE_RAW_MGM_HK = ["1", "mgm_raw_enable_hk"] DISABLE_RAW_MGM_HK = ["2", "mgm_raw_disable_hk"] @@ -100,6 +106,8 @@ class Info: TARGET = "Switch ACS CTRL normal - pointing target" GS = "Switch ACS CTRL normal - pointing target groundstation" INERTIAL = "Switch ACS CTRL normal - pointing inertial" + SAFE_PTG = "Confirm deployment of both solar arrays" + RESET_MEKF = "Reset the MEKF" REQUEST_RAW_MGM_HK = "Request Raw MGM HK once" ENABLE_RAW_MGM_HK = "Enable Raw MGM HK data generation" DISABLE_RAW_MGM_HK = "Disable Raw MGM HK data generation" @@ -155,6 +163,8 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.TARGET, info=Info.TARGET) oce.add(keys=OpCodes.GS, info=Info.GS) oce.add(keys=OpCodes.INERTIAL, info=Info.INERTIAL) + oce.add(keys=OpCodes.SAFE_PTG, info=Info.SAFE_PTG) + oce.add(keys=OpCodes.RESET_MEKF, info=Info.RESET_MEKF) oce.add(keys=OpCodes.REQUEST_RAW_MGM_HK, info=Info.REQUEST_RAW_MGM_HK) oce.add(keys=OpCodes.ENABLE_RAW_MGM_HK, info=Info.ENABLE_RAW_MGM_HK) oce.add(keys=OpCodes.DISABLE_RAW_MGM_HK, info=Info.DISABLE_RAW_MGM_HK) @@ -218,6 +228,12 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.INERTIAL: q.add_log_cmd(f"{Info.INERTIAL}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_INERTIAL)) + elif op_code in OpCodes.SAFE_PTG: + q.add_log_cmd(f"{Info.SAFE_PTG}") + q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL)) + elif op_code in OpCodes.RESET_MEKF: + q.add_log_cmd(f"{Info.RESET_MEKF}") + q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.RESET_MEKF)) elif op_code in OpCodes.REQUEST_RAW_MGM_HK: q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) q.add_pus_tc( From 7a82a77876d80d3f082b574d10e44d49dad00d54 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 15:24:57 +0100 Subject: [PATCH 05/10] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 108f06e..5904540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ list yields a list of all related PRs for each release. # [unreleased] +- added ACS action cmds +- fixed diag related ACS hk cmds + # [v2.15.2] 2023-02-23 - Update of generated returnvalue and event files. From 3f7147586093e0a72b05dcc592ddd9546adba200 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Feb 2023 15:28:58 +0100 Subject: [PATCH 06/10] uptd --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index beb7f82..343875d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,13 @@ list yields a list of all related PRs for each release. # [unreleased] +## Added + - added ACS action cmds +- added new ACS hk values + +## Ficed + - fixed diag related ACS hk cmds # [v2.16.0] 2023-02-23 From 6a30f6d0ac4132e67d373bc04b1a666839b2b490 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 27 Feb 2023 14:01:54 +0100 Subject: [PATCH 07/10] added commands to change scalar and vector parameters --- eive_tmtc/tmtc/acs/acs_ctrl.py | 147 ++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 16e398a..2c19d68 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -14,6 +14,7 @@ from tmtccmd.config.tmtc import ( OpCodeEntry, ) from tmtccmd.tc import service_provider +from tmtccmd.tc.queue import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_command from tmtccmd.tc.decorator import ServiceProviderParams from tmtccmd.tc.pus_3_fsfw_hk import ( @@ -26,6 +27,20 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.tc.pus_20_fsfw_param import ( + create_load_param_cmd +) + +from tmtccmd.pus.s20_fsfw_param_defs import ( + create_scalar_u8_parameter, + create_scalar_u16_parameter, + create_scalar_u32_parameter, + create_scalar_float_parameter, + create_scalar_double_parameter, + create_vector_float_parameter, + create_vector_double_parameter, +) + class SetId(enum.IntEnum): MGM_RAW_SET = 0 @@ -65,6 +80,8 @@ class OpCodes: INERTIAL = ["normal_inertial"] SAFE_PTG = ["confirm_deployment"] RESET_MEKF = ["reset_mekf"] + SET_PARAMETER_SCALAR = ["set_scalar_param"] + SET_PARAMETER_VECTOR = ["set_vector_param"] REQUEST_RAW_MGM_HK = ["0", "mgm_raw_hk"] ENABLE_RAW_MGM_HK = ["1", "mgm_raw_enable_hk"] DISABLE_RAW_MGM_HK = ["2", "mgm_raw_disable_hk"] @@ -108,6 +125,9 @@ class Info: INERTIAL = "Switch ACS CTRL normal - pointing inertial" SAFE_PTG = "Confirm deployment of both solar arrays" RESET_MEKF = "Reset the MEKF" + SET_PARAMETER_SCALAR = "Set Scalar Parameter" + SET_PARAMETER_VECTOR = "Set Vector Parameter" + SET_PARAMETER_MATRIX = "Set Matrix Parameter" REQUEST_RAW_MGM_HK = "Request Raw MGM HK once" ENABLE_RAW_MGM_HK = "Enable Raw MGM HK data generation" DISABLE_RAW_MGM_HK = "Disable Raw MGM HK data generation" @@ -165,6 +185,8 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.INERTIAL, info=Info.INERTIAL) oce.add(keys=OpCodes.SAFE_PTG, info=Info.SAFE_PTG) oce.add(keys=OpCodes.RESET_MEKF, info=Info.RESET_MEKF) + oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR) + oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR) oce.add(keys=OpCodes.REQUEST_RAW_MGM_HK, info=Info.REQUEST_RAW_MGM_HK) oce.add(keys=OpCodes.ENABLE_RAW_MGM_HK, info=Info.ENABLE_RAW_MGM_HK) oce.add(keys=OpCodes.DISABLE_RAW_MGM_HK, info=Info.DISABLE_RAW_MGM_HK) @@ -234,6 +256,12 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.RESET_MEKF: q.add_log_cmd(f"{Info.RESET_MEKF}") q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.RESET_MEKF)) + elif op_code in OpCodes.SET_PARAMETER_SCALAR: + q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}") + set_acs_ctrl_param_scalar(q) + elif op_code in OpCodes.SET_PARAMETER_VECTOR: + q.add_log_cmd(f"{Info.SET_PARAMETER_VECTOR}") + set_acs_ctrl_param_vector(q) elif op_code in OpCodes.REQUEST_RAW_MGM_HK: q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) q.add_pus_tc( @@ -426,6 +454,121 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): logging.getLogger(__name__).info(f"Unknown op code {op_code}") +def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): + pt = int(input("Specify parameter type to set {0: \"uint8\", 1: \"uint16\", 2: \"uint32\", 3: \"float\", " + "4: \"double\"}: ")) + sid = int(input("Specify parameter struct ID to set: ")) + pid = int(input("Specify parameter ID to set: ")) + match pt: + case 0: + param = int(input("Specify parameter value to set: ")) + q.add_pus_tc( + create_load_param_cmd( + create_scalar_u8_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameter=param, + ).pack() + ) + ) + case 1: + param = int(input("Specify parameter value to set: ")) + q.add_pus_tc( + create_load_param_cmd( + create_scalar_u16_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameter=param, + ).pack() + ) + ) + case 2: + param = int(input("Specify parameter value to set: ")) + q.add_pus_tc( + create_load_param_cmd( + create_scalar_u32_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameter=param, + ).pack() + ) + ) + case 3: + param = float(input("Specify parameter value to set: ")) + q.add_pus_tc( + create_load_param_cmd( + create_scalar_float_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameter=param, + ).pack() + ) + ) + case 4: + param = float(input("Specify parameter value to set: ")) + q.add_pus_tc( + create_load_param_cmd( + create_scalar_double_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameter=param, + ).pack() + ) + ) + + +def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): + pt = int(input("Specify parameter type to set {0: \"float\", 1: \"double\"}: ")) + sid = int(input("Specify parameter struct ID to set: ")) + pid = int(input("Specify parameter ID to set: ")) + match pt: + case 0: + nr = int(input("Specify number of elements in vector to set: ")) + param = [] + for _ in range(nr): + param.append(float(input("Specify parameter vector entry value to set: "))) + print(param) + if bool(input("Confirm selected parameter values (Y/N): ")): + q.add_pus_tc( + create_load_param_cmd( + create_vector_float_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameters=param, + ).pack() + ) + ) + else: + print("Aborting") + return + case 1: + nr = int(input("Specify number of elements in vector to set: ")) + param = [] + for _ in range(nr): + param.append(float(input("Specify parameter vector entry value to set: "))) + print(param) + if bool(input("Confirm selected parameter values (Y/N): ")): + q.add_pus_tc( + create_load_param_cmd( + create_vector_double_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameters=param, + ).pack() + ) + ) + else: + print("Aborting") + return + + def handle_acs_ctrl_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes): pw = PrintWrapper(printer) match set_id: @@ -724,7 +867,7 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): - mekfStatus = {0 : "UNINITIALIZED", 1: "NO_GYR_DATA", 2: "NO_MODEL_VECTORS", 3: "NO_SUS_MGM_STR_DATA", + mekf_status = {0 : "UNINITIALIZED", 1: "NO_GYR_DATA", 2: "NO_MODEL_VECTORS", 3: "NO_SUS_MGM_STR_DATA", 4: "COVARIANCE_INVERSION_FAILED", 10: "INITIALIZED", 11: "RUNNING"} pw.dlog("Received MEKF Set") fmt_quat = "!dddd" @@ -745,7 +888,7 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): current_idx += inc_len_vec status = struct.unpack(fmt_sts, hk_data[current_idx : current_idx + inc_len_sts])[0] current_idx += inc_len_sts - pw.dlog(f"{'MEKF Status'.ljust(25)}: {mekfStatus[status]}") + pw.dlog(f"{'MEKF Status'.ljust(25)}: {mekf_status[status]}") pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}") pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rate)}") pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=3) From 736bc23fc5f8174bdc573d8714cfa487e463de1c Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 27 Feb 2023 15:04:02 +0100 Subject: [PATCH 08/10] added command to set matrix parameter --- eive_tmtc/tmtc/acs/acs_ctrl.py | 75 +++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 2c19d68..73b46e0 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -39,6 +39,8 @@ from tmtccmd.pus.s20_fsfw_param_defs import ( create_scalar_double_parameter, create_vector_float_parameter, create_vector_double_parameter, + create_matrix_float_parameter, + create_matrix_double_parameter, ) @@ -82,6 +84,7 @@ class OpCodes: RESET_MEKF = ["reset_mekf"] SET_PARAMETER_SCALAR = ["set_scalar_param"] SET_PARAMETER_VECTOR = ["set_vector_param"] + SET_PARAMETER_MATRIX = ["set_matrix_param"] REQUEST_RAW_MGM_HK = ["0", "mgm_raw_hk"] ENABLE_RAW_MGM_HK = ["1", "mgm_raw_enable_hk"] DISABLE_RAW_MGM_HK = ["2", "mgm_raw_disable_hk"] @@ -187,6 +190,7 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.RESET_MEKF, info=Info.RESET_MEKF) oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR) oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR) + oce.add(keys=OpCodes.SET_PARAMETER_MATRIX, info=Info.SET_PARAMETER_MATRIX) oce.add(keys=OpCodes.REQUEST_RAW_MGM_HK, info=Info.REQUEST_RAW_MGM_HK) oce.add(keys=OpCodes.ENABLE_RAW_MGM_HK, info=Info.ENABLE_RAW_MGM_HK) oce.add(keys=OpCodes.DISABLE_RAW_MGM_HK, info=Info.DISABLE_RAW_MGM_HK) @@ -262,6 +266,9 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): elif op_code in OpCodes.SET_PARAMETER_VECTOR: q.add_log_cmd(f"{Info.SET_PARAMETER_VECTOR}") set_acs_ctrl_param_vector(q) + elif op_code in OpCodes.SET_PARAMETER_MATRIX: + q.add_log_cmd(f"{Info.SET_PARAMETER_MATRIX}") + set_acs_ctrl_param_matrix(q) elif op_code in OpCodes.REQUEST_RAW_MGM_HK: q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) q.add_pus_tc( @@ -528,12 +535,12 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): pid = int(input("Specify parameter ID to set: ")) match pt: case 0: - nr = int(input("Specify number of elements in vector to set: ")) + elms = int(input("Specify number of elements in vector to set: ")) param = [] - for _ in range(nr): + for _ in range(elms): param.append(float(input("Specify parameter vector entry value to set: "))) print(param) - if bool(input("Confirm selected parameter values (Y/N): ")): + if input("Confirm selected parameter values (Y/N): ") == "Y": q.add_pus_tc( create_load_param_cmd( create_vector_float_parameter( @@ -548,12 +555,12 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): print("Aborting") return case 1: - nr = int(input("Specify number of elements in vector to set: ")) + elms = int(input("Specify number of elements in vector to set: ")) param = [] - for _ in range(nr): + for _ in range(elms): param.append(float(input("Specify parameter vector entry value to set: "))) print(param) - if bool(input("Confirm selected parameter values (Y/N): ")): + if input("Confirm selected parameter values (Y/N): ") == "Y": q.add_pus_tc( create_load_param_cmd( create_vector_double_parameter( @@ -569,6 +576,62 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): return +def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper): + pt = int(input("Specify parameter type to set {0: \"float\", 1: \"double\"}: ")) + sid = int(input("Specify parameter struct ID to set: ")) + pid = int(input("Specify parameter ID to set: ")) + match pt: + case 0: + rows = int(input("Specify number of rows in matrix to set: ")) + cols = int(input("Specify number of columns in matrix to set: ")) + row = [] + param = [] + for _ in range(rows): + for _ in range(cols): + row.append(float(input("Specify parameter vector entry value to set: "))) + param.append(row) + print(param) + if input("Confirm selected parameter values (Y/N): ") == "Y": + q.add_pus_tc( + create_load_param_cmd( + create_matrix_float_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameters=param, + ).pack() + ) + ) + else: + print("Aborting") + return + case 1: + rows = int(input("Specify number of rows in matrix to set: ")) + cols = int(input("Specify number of columns in matrix to set: ")) + row = [] + param = [] + for _ in range(rows): + for _ in range(cols): + row.append(float(input("Specify parameter vector entry value to set: "))) + param.append(row) + row = [] + print(param) + if input("Confirm selected parameter values (Y/N): ") == "Y": + q.add_pus_tc( + create_load_param_cmd( + create_matrix_double_parameter( + object_id=ACS_CONTROLLER, + domain_id=sid, + unique_id=pid, + parameters=param, + ).pack() + ) + ) + else: + print("Aborting") + return + + def handle_acs_ctrl_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes): pw = PrintWrapper(printer) match set_id: From b4438675129d847e26e5116eb970ed80d95fd573 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 28 Feb 2023 11:02:59 +0100 Subject: [PATCH 09/10] final fixes --- eive_tmtc/tmtc/acs/acs_ctrl.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 73b46e0..9df6fcf 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -34,7 +34,7 @@ from tmtccmd.tc.pus_20_fsfw_param import ( from tmtccmd.pus.s20_fsfw_param_defs import ( create_scalar_u8_parameter, create_scalar_u16_parameter, - create_scalar_u32_parameter, + create_scalar_i32_parameter, create_scalar_float_parameter, create_scalar_double_parameter, create_vector_float_parameter, @@ -462,7 +462,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): - pt = int(input("Specify parameter type to set {0: \"uint8\", 1: \"uint16\", 2: \"uint32\", 3: \"float\", " + pt = int(input("Specify parameter type to set {0: \"uint8\", 1: \"uint16\", 2: \"int32\", 3: \"float\", " "4: \"double\"}: ")) sid = int(input("Specify parameter struct ID to set: ")) pid = int(input("Specify parameter ID to set: ")) @@ -495,7 +495,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): param = int(input("Specify parameter value to set: ")) q.add_pus_tc( create_load_param_cmd( - create_scalar_u32_parameter( + create_scalar_i32_parameter( object_id=ACS_CONTROLLER, domain_id=sid, unique_id=pid, @@ -552,7 +552,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): ) ) else: - print("Aborting") + q.add_log_cmd("Aborted by user input") return case 1: elms = int(input("Specify number of elements in vector to set: ")) @@ -572,7 +572,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): ) ) else: - print("Aborting") + q.add_log_cmd("Aborted by user input") return @@ -603,7 +603,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper): ) ) else: - print("Aborting") + q.add_log_cmd("Aborted by user input") return case 1: rows = int(input("Specify number of rows in matrix to set: ")) @@ -628,7 +628,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper): ) ) else: - print("Aborting") + q.add_log_cmd("Aborted by user input") return From 001270a1e5dde80362e306a30ae02b02a9ee63fd Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 28 Feb 2023 11:03:16 +0100 Subject: [PATCH 10/10] changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f726426..2cde35c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,13 +12,14 @@ list yields a list of all related PRs for each release. ## Added -- added ACS action cmds -- added new ACS hk values +- Added ACS action cmds +- Added new ACS hk values +- Added ACS set parameter cmds ## Fixed - Correction for ACS CTRL raw data requests HK type -- fixed diag related ACS hk cmds +- Fixed diag related ACS hk cmds # [v2.16.1] 2023-02-24