From 0bdc8f04a84eea798018f05cc31d079739eab527 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 11:07:54 +0100 Subject: [PATCH] added first ACS ASS command --- config/definitions.py | 1 + config/hook_implementations.py | 2 ++ pus_tc/cmd_definitions.py | 17 +++++++++++++++++ pus_tc/system/acs.py | 18 ++++++++++++------ pus_tc/tc_packer_hook.py | 2 ++ tmtccli.py | 8 +++----- tmtccmd | 2 +- 7 files changed, 38 insertions(+), 12 deletions(-) diff --git a/config/definitions.py b/config/definitions.py index d1a2cdf..ded12d5 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -42,3 +42,4 @@ class CustomServiceList(enum.Enum): PDEC_HANDLER = "pdec_handler" STR_IMG_HELPER = "str_img_helper" SYRLINKS = "syrlinks" + ACS_ASS = "acs-ass" diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 8e3e454..f8e7a60 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -125,6 +125,7 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): add_rw_cmds, add_rad_sens_cmds, add_ploc_cmds, + add_system_cmds ) from pus_tc.devs.gps import GpsOpCodes @@ -136,6 +137,7 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): add_rad_sens_cmds(cmd_dict=service_op_code_dict) add_rw_cmds(cmd_dict=service_op_code_dict) add_ploc_cmds(cmd_dict=service_op_code_dict) + add_system_cmds(cmd_dict=service_op_code_dict) op_code_dict = { GpsOpCodes.RESET_GNSS.value: ("Reset GPS", {OpCodeDictKeys.TIMEOUT: 2.0}) diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index 316e9c9..d3d02e1 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -511,3 +511,20 @@ def add_ploc_cmds(cmd_dict: ServiceOpCodeDictT): cmd_dict[ CustomServiceList.PLOC_MEMORY_DUMPER.value ] = service_ploc_memory_dumper_tuple + + +def add_system_cmds(cmd_dict: ServiceOpCodeDictT): + from pus_tc.system.acs import AcsOpCodes + + op_code_dict = dict() + add_op_code_entry( + op_code_dict=op_code_dict, + keys=AcsOpCodes.ACS_ASS_A_SIDE, + info="Switch to ACS board A side", + ) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.ACS_ASS.value, + info="ACS Assemblies", + op_code_entry=op_code_dict, + ) diff --git a/pus_tc/system/acs.py b/pus_tc/system/acs.py index 3e8dbbc..f2a2471 100644 --- a/pus_tc/system/acs.py +++ b/pus_tc/system/acs.py @@ -1,10 +1,11 @@ import enum -from tmtccmd.tc.definitions import TcQueueT -from tmtccmd.tc.service_200_mode import pack_mode_data, Modes +from tmtccmd.tc.definitions import TcQueueT, QueueCommands +from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.tc.service_200_mode import pack_mode_data, Modes, Subservices from config.object_ids import ACS_BOARD_ASS_ID -class AcsOpCodes(enum.Enum): +class AcsOpCodes: ACS_ASS_A_SIDE = ["0", "a"] ACS_ASS_B_SIDE = ["1", "b"] ACS_ASS_DUAL_MODE = ["2", "d"] @@ -17,11 +18,16 @@ class AcsBoardSubmodes(enum.IntEnum): def pack_acs_command(tc_queue: TcQueueT, op_code: str): - if op_code == AcsOpCodes.ACS_ASS_A_SIDE: + if op_code in AcsOpCodes.ACS_ASS_A_SIDE: + tc_queue.appendleft((QueueCommands.PRINT, "Switching to ACS board assembly A side")) mode_data = pack_mode_data( object_id=ACS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=AcsBoardSubmodes.A_SIDE, ) - - pass + cmd = PusTelecommand( + service=200, + subservice=Subservices.COMMAND_MODE_COMMAND, + app_data=mode_data + ) + tc_queue.appendleft(cmd.pack_command_tuple()) diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index f23c714..340a8ac 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -195,6 +195,8 @@ def pack_service_queue_user( ) if service == CustomServiceList.PL_PCDU.value: return pack_pl_pcdu_commands(tc_queue=service_queue, op_code=op_code) + if service == CustomServiceList.ACS_ASS.value: + return pack_acs_command(tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !") diff --git a/tmtccli.py b/tmtccli.py index 70ffefe..9561eb9 100755 --- a/tmtccli.py +++ b/tmtccli.py @@ -27,6 +27,7 @@ limitations under the License. @author R. Mueller """ import sys +import traceback try: from tmtccmd.runner import ( @@ -39,12 +40,9 @@ try: except ImportError as error: run_tmtc_commander = None initialize_tmtc_commander = None - print(error) + tb = traceback.format_exc() + print(tb) print("Python tmtccmd submodule could not be imported") - print( - 'Install with "cd tmtccmd && python3 -m pip ' - 'install -e .[gui]" for interactive installation' - ) sys.exit(1) try: diff --git a/tmtccmd b/tmtccmd index 67fd6ef..0f4d473 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 67fd6ef97435a6f6098792ab8d04ecba6be5dda4 +Subproject commit 0f4d4730ab35163c5a06138f4b54e4eaf89bc24c