From 275d79d179dc29ed25d7c08bc05805419cf03ab1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Jul 2021 00:24:09 +0200 Subject: [PATCH] common tmtc folder --- example_common | 2 +- fsfw | 2 +- tmtc/{config => common_tmtc}/__init__.py | 0 .../config}/__init__.py | 0 .../config/custom_definitions.py | 0 .../config/custom_mode_op.py | 0 tmtc/{ => common_tmtc}/config/definitions.py | 0 .../config/hook_implementation.py | 17 +++++++------- tmtc/{ => common_tmtc}/config/object_ids.py | 0 .../{ => common_tmtc}/config/tmtc_config.json | 0 tmtc/{ => common_tmtc}/config/version.py | 0 .../pus_tc}/__init__.py | 0 tmtc/{ => common_tmtc}/pus_tc/command_data.py | 0 .../pus_tc/service_17_test.py | 0 .../pus_tc/service_200_mode.py | 2 +- .../pus_tc/service_20_parameters.py | 2 +- .../pus_tc/service_2_raw_cmd.py | 6 ++--- .../pus_tc/service_3_housekeeping.py | 2 +- .../pus_tc/service_8_func_cmd.py | 6 ++--- tmtc/{ => common_tmtc}/pus_tc/tc_packing.py | 12 +++++----- tmtc/common_tmtc/pus_tm/__init__.py | 0 tmtc/{ => common_tmtc}/pus_tm/factory_hook.py | 2 +- .../pus_tm/service_3_hk_handling.py | 6 ++--- .../pus_tm/service_8_handling.py | 0 tmtc/tmtc_client_cli.py | 6 ++--- tmtc/tmtc_client_gui.py | 22 ++++++++++++++++--- 26 files changed, 52 insertions(+), 35 deletions(-) rename tmtc/{config => common_tmtc}/__init__.py (100%) rename tmtc/{pus_tc => common_tmtc/config}/__init__.py (100%) rename tmtc/{ => common_tmtc}/config/custom_definitions.py (100%) rename tmtc/{ => common_tmtc}/config/custom_mode_op.py (100%) rename tmtc/{ => common_tmtc}/config/definitions.py (100%) rename tmtc/{ => common_tmtc}/config/hook_implementation.py (83%) rename tmtc/{ => common_tmtc}/config/object_ids.py (100%) rename tmtc/{ => common_tmtc}/config/tmtc_config.json (100%) rename tmtc/{ => common_tmtc}/config/version.py (100%) rename tmtc/{pus_tm => common_tmtc/pus_tc}/__init__.py (100%) rename tmtc/{ => common_tmtc}/pus_tc/command_data.py (100%) rename tmtc/{ => common_tmtc}/pus_tc/service_17_test.py (100%) rename tmtc/{ => common_tmtc}/pus_tc/service_200_mode.py (97%) rename tmtc/{ => common_tmtc}/pus_tc/service_20_parameters.py (98%) rename tmtc/{ => common_tmtc}/pus_tc/service_2_raw_cmd.py (95%) rename tmtc/{ => common_tmtc}/pus_tc/service_3_housekeeping.py (98%) rename tmtc/{ => common_tmtc}/pus_tc/service_8_func_cmd.py (93%) rename tmtc/{ => common_tmtc}/pus_tc/tc_packing.py (80%) create mode 100644 tmtc/common_tmtc/pus_tm/__init__.py rename tmtc/{ => common_tmtc}/pus_tm/factory_hook.py (97%) rename tmtc/{ => common_tmtc}/pus_tm/service_3_hk_handling.py (94%) rename tmtc/{ => common_tmtc}/pus_tm/service_8_handling.py (100%) diff --git a/example_common b/example_common index e487913..49566cd 160000 --- a/example_common +++ b/example_common @@ -1 +1 @@ -Subproject commit e4879130b09c76dac75265768fc757759e9aedcd +Subproject commit 49566cd1301cffad09defd4051b66f0129d82f17 diff --git a/fsfw b/fsfw index 3a9add8..66a79cb 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3a9add82fe56b4b75b0079b48c094e6c4f778c42 +Subproject commit 66a79cb86c061a7113a43a21035f1fdb1e082729 diff --git a/tmtc/config/__init__.py b/tmtc/common_tmtc/__init__.py similarity index 100% rename from tmtc/config/__init__.py rename to tmtc/common_tmtc/__init__.py diff --git a/tmtc/pus_tc/__init__.py b/tmtc/common_tmtc/config/__init__.py similarity index 100% rename from tmtc/pus_tc/__init__.py rename to tmtc/common_tmtc/config/__init__.py diff --git a/tmtc/config/custom_definitions.py b/tmtc/common_tmtc/config/custom_definitions.py similarity index 100% rename from tmtc/config/custom_definitions.py rename to tmtc/common_tmtc/config/custom_definitions.py diff --git a/tmtc/config/custom_mode_op.py b/tmtc/common_tmtc/config/custom_mode_op.py similarity index 100% rename from tmtc/config/custom_mode_op.py rename to tmtc/common_tmtc/config/custom_mode_op.py diff --git a/tmtc/config/definitions.py b/tmtc/common_tmtc/config/definitions.py similarity index 100% rename from tmtc/config/definitions.py rename to tmtc/common_tmtc/config/definitions.py diff --git a/tmtc/config/hook_implementation.py b/tmtc/common_tmtc/config/hook_implementation.py similarity index 83% rename from tmtc/config/hook_implementation.py rename to tmtc/common_tmtc/config/hook_implementation.py index 63bcbd3..768ea8f 100644 --- a/tmtc/config/hook_implementation.py +++ b/tmtc/common_tmtc/config/hook_implementation.py @@ -5,19 +5,18 @@ from tmtccmd.com_if.com_interface_base import CommunicationInterface from tmtccmd.config.definitions import ServiceOpCodeDictT from tmtccmd.config.hook import TmTcHookBase from tmtccmd.core.backend import TmTcHandler -from tmtccmd.ecss.tm import PusTelemetry from tmtccmd.pus_tc.definitions import TcQueueT from tmtccmd.pus_tm.service_3_base import Service3Base from tmtccmd.ecss.conf import PusVersion from tmtccmd.utility.tmtc_printer import TmTcPrinter -from config.definitions import PUS_APID +from common_tmtc.config.definitions import PUS_APID class FsfwHookBase(TmTcHookBase): def get_version(self) -> str: - from config.version import SW_NAME, SW_VERSION, SW_SUBVERSION, SW_SUBSUBVERSION + from common_tmtc.config.version import SW_NAME, SW_VERSION, SW_SUBVERSION, SW_SUBSUBVERSION return f"{SW_NAME} {SW_VERSION}.{SW_SUBVERSION}.{SW_SUBSUBVERSION}" def get_json_config_file_path(self) -> str: @@ -35,7 +34,9 @@ class FsfwHookBase(TmTcHookBase): def add_globals_post_args_parsing(self, args: argparse.Namespace): from tmtccmd.config.globals import set_default_globals_post_args_parsing - set_default_globals_post_args_parsing(args=args, json_cfg_path=self.get_json_config_file_path()) + set_default_globals_post_args_parsing( + args=args, json_cfg_path=self.get_json_config_file_path() + ) def assign_communication_interface( self, com_if_key: str, tmtc_printer: TmTcPrinter @@ -50,18 +51,18 @@ class FsfwHookBase(TmTcHookBase): print("No custom mode operation implemented") def pack_service_queue(self, service: int, op_code: str, service_queue: TcQueueT): - from pus_tc.tc_packing import pack_service_queue_user + from common_tmtc.pus_tc.tc_packing import pack_service_queue_user pack_service_queue_user(service=service, op_code=op_code, tc_queue=service_queue) def get_object_ids(self) -> Dict[bytes, list]: - from config.object_ids import get_object_ids + from common_tmtc.config.object_ids import get_object_ids return get_object_ids() @staticmethod def handle_service_8_telemetry( object_id: int, action_id: int, custom_data: bytearray ) -> Tuple[list, list]: - from pus_tm.service_8_handling import custom_service_8_handling + from common_tmtc.pus_tm.service_8_handling import custom_service_8_handling return custom_service_8_handling( object_id=object_id, action_id=action_id, custom_data=custom_data ) @@ -70,7 +71,7 @@ class FsfwHookBase(TmTcHookBase): def handle_service_3_housekeeping( object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base ) -> Tuple[list, list, bytearray, int]: - from pus_tm.service_3_hk_handling import service_3_hk_handling + from common_tmtc.pus_tm import service_3_hk_handling return service_3_hk_handling( object_id=object_id, set_id=set_id, hk_data=hk_data, service3_packet=service3_packet ) diff --git a/tmtc/config/object_ids.py b/tmtc/common_tmtc/config/object_ids.py similarity index 100% rename from tmtc/config/object_ids.py rename to tmtc/common_tmtc/config/object_ids.py diff --git a/tmtc/config/tmtc_config.json b/tmtc/common_tmtc/config/tmtc_config.json similarity index 100% rename from tmtc/config/tmtc_config.json rename to tmtc/common_tmtc/config/tmtc_config.json diff --git a/tmtc/config/version.py b/tmtc/common_tmtc/config/version.py similarity index 100% rename from tmtc/config/version.py rename to tmtc/common_tmtc/config/version.py diff --git a/tmtc/pus_tm/__init__.py b/tmtc/common_tmtc/pus_tc/__init__.py similarity index 100% rename from tmtc/pus_tm/__init__.py rename to tmtc/common_tmtc/pus_tc/__init__.py diff --git a/tmtc/pus_tc/command_data.py b/tmtc/common_tmtc/pus_tc/command_data.py similarity index 100% rename from tmtc/pus_tc/command_data.py rename to tmtc/common_tmtc/pus_tc/command_data.py diff --git a/tmtc/pus_tc/service_17_test.py b/tmtc/common_tmtc/pus_tc/service_17_test.py similarity index 100% rename from tmtc/pus_tc/service_17_test.py rename to tmtc/common_tmtc/pus_tc/service_17_test.py diff --git a/tmtc/pus_tc/service_200_mode.py b/tmtc/common_tmtc/pus_tc/service_200_mode.py similarity index 97% rename from tmtc/pus_tc/service_200_mode.py rename to tmtc/common_tmtc/pus_tc/service_200_mode.py index 11a8363..eac75a1 100644 --- a/tmtc/pus_tc/service_200_mode.py +++ b/tmtc/common_tmtc/pus_tc/service_200_mode.py @@ -10,7 +10,7 @@ from tmtccmd.ecss.tc import PusTelecommand from tmtccmd.pus_tc.packer import TcQueueT from tmtccmd.pus_tc.service_200_mode import pack_mode_data -from config.object_ids import TEST_DEVICE_0_ID +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID def pack_service_200_commands_into(tc_queue: TcQueueT, op_code: str): diff --git a/tmtc/pus_tc/service_20_parameters.py b/tmtc/common_tmtc/pus_tc/service_20_parameters.py similarity index 98% rename from tmtc/pus_tc/service_20_parameters.py rename to tmtc/common_tmtc/pus_tc/service_20_parameters.py index 9224137..3ee5564 100644 --- a/tmtc/pus_tc/service_20_parameters.py +++ b/tmtc/common_tmtc/pus_tc/service_20_parameters.py @@ -8,7 +8,7 @@ from tmtccmd.pus_tc.service_20_parameter import pack_type_and_matrix_data, \ from tmtccmd.pus_tc.service_200_mode import pack_mode_data from tmtccmd.utility.logger import get_console_logger -from config.object_ids import TEST_DEVICE_0_ID +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID LOGGER = get_console_logger() diff --git a/tmtc/pus_tc/service_2_raw_cmd.py b/tmtc/common_tmtc/pus_tc/service_2_raw_cmd.py similarity index 95% rename from tmtc/pus_tc/service_2_raw_cmd.py rename to tmtc/common_tmtc/pus_tc/service_2_raw_cmd.py index f26f33e..450bfd1 100644 --- a/tmtc/pus_tc/service_2_raw_cmd.py +++ b/tmtc/common_tmtc/pus_tc/service_2_raw_cmd.py @@ -10,10 +10,10 @@ import struct from tmtccmd.config.definitions import QueueCommands from tmtccmd.ecss.tc import PusTelecommand from tmtccmd.pus_tc.definitions import TcQueueT -from pus_tc.service_200_mode import pack_mode_data +from common_tmtc.pus_tc.service_200_mode import pack_mode_data -import pus_tc.command_data as cmd_data -from config.object_ids import TEST_DEVICE_0_ID +from common_tmtc import pus_tc as cmd_data +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID def pack_service_2_commands_into(tc_queue: TcQueueT, op_code: str): diff --git a/tmtc/pus_tc/service_3_housekeeping.py b/tmtc/common_tmtc/pus_tc/service_3_housekeeping.py similarity index 98% rename from tmtc/pus_tc/service_3_housekeeping.py rename to tmtc/common_tmtc/pus_tc/service_3_housekeeping.py index a5b4f94..7c4268d 100644 --- a/tmtc/pus_tc/service_3_housekeeping.py +++ b/tmtc/common_tmtc/pus_tc/service_3_housekeeping.py @@ -7,7 +7,7 @@ from tmtccmd.ecss.tc import PusTelecommand from tmtccmd.pus_tc.definitions import TcQueueT from tmtccmd.pus_tc.service_8_functional_cmd import generate_action_command -from config.object_ids import TEST_DEVICE_0_ID, TEST_DEVICE_1_ID +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID, TEST_DEVICE_1_ID # Set IDs diff --git a/tmtc/pus_tc/service_8_func_cmd.py b/tmtc/common_tmtc/pus_tc/service_8_func_cmd.py similarity index 93% rename from tmtc/pus_tc/service_8_func_cmd.py rename to tmtc/common_tmtc/pus_tc/service_8_func_cmd.py index a53d44b..81a3f3c 100644 --- a/tmtc/pus_tc/service_8_func_cmd.py +++ b/tmtc/common_tmtc/pus_tc/service_8_func_cmd.py @@ -2,10 +2,10 @@ from tmtccmd.config.definitions import QueueCommands from tmtccmd.ecss.tc import PusTelecommand from tmtccmd.pus_tc.definitions import TcQueueT -import pus_tc.command_data as cmd_data -from pus_tc.service_200_mode import pack_mode_data +from common_tmtc import pus_tc as cmd_data +from common_tmtc.pus_tc.service_200_mode import pack_mode_data -from config.object_ids import TEST_DEVICE_0_ID +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID def pack_service_8_commands_into(tc_queue: TcQueueT, op_code: str): diff --git a/tmtc/pus_tc/tc_packing.py b/tmtc/common_tmtc/pus_tc/tc_packing.py similarity index 80% rename from tmtc/pus_tc/tc_packing.py rename to tmtc/common_tmtc/pus_tc/tc_packing.py index 7e09646..c4d1113 100644 --- a/tmtc/pus_tc/tc_packing.py +++ b/tmtc/common_tmtc/pus_tc/tc_packing.py @@ -8,17 +8,17 @@ import os from collections import deque from typing import Union -from pus_tc.service_20_parameters import pack_service20_commands_into -from pus_tc.service_2_raw_cmd import pack_service_2_commands_into -from pus_tc.service_3_housekeeping import pack_service_3_commands_into -from pus_tc.service_17_test import pack_service_17_commands -from pus_tc.service_8_func_cmd import pack_service_8_commands_into +from common_tmtc.pus_tc.service_20_parameters import pack_service20_commands_into +from common_tmtc.pus_tc.service_2_raw_cmd import pack_service_2_commands_into +from common_tmtc.pus_tc.service_3_housekeeping import pack_service_3_commands_into +from common_tmtc.pus_tc.service_17_test import pack_service_17_commands +from common_tmtc.pus_tc.service_8_func_cmd import pack_service_8_commands_into from tmtccmd.utility.logger import get_console_logger from tmtccmd.pus_tc.definitions import TcQueueT from tmtccmd.config.definitions import CoreServiceList from tmtccmd.pus_tc.service_5_event import pack_generic_service5_test_into from tmtccmd.pus_tc.service_17_test import pack_generic_service17_test -from pus_tc.service_200_mode import pack_service_200_commands_into +from common_tmtc.pus_tc.service_200_mode import pack_service_200_commands_into LOGGER = get_console_logger() diff --git a/tmtc/common_tmtc/pus_tm/__init__.py b/tmtc/common_tmtc/pus_tm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tmtc/pus_tm/factory_hook.py b/tmtc/common_tmtc/pus_tm/factory_hook.py similarity index 97% rename from tmtc/pus_tm/factory_hook.py rename to tmtc/common_tmtc/pus_tm/factory_hook.py index 441f053..3bd23a3 100644 --- a/tmtc/pus_tm/factory_hook.py +++ b/tmtc/common_tmtc/pus_tm/factory_hook.py @@ -16,7 +16,7 @@ from tmtccmd.pus_tm.service_20_parameters import Service20TM from tmtccmd.pus_tm.service_200_mode import Service200TM from tmtccmd.utility.tmtc_printer import TmTcPrinter -from config.definitions import PUS_APID +from common_tmtc.config.definitions import PUS_APID LOGGER = get_console_logger() diff --git a/tmtc/pus_tm/service_3_hk_handling.py b/tmtc/common_tmtc/pus_tm/service_3_hk_handling.py similarity index 94% rename from tmtc/pus_tm/service_3_hk_handling.py rename to tmtc/common_tmtc/pus_tm/service_3_hk_handling.py index 138ae00..d9966f7 100644 --- a/tmtc/pus_tm/service_3_hk_handling.py +++ b/tmtc/common_tmtc/pus_tm/service_3_hk_handling.py @@ -7,10 +7,10 @@ import struct from typing import Tuple from tmtccmd.pus_tm.service_3_housekeeping import Service3Base -from tmtccmd.utility.logger import get_logger +from tmtccmd.utility.logger import get_console_logger -from config.object_ids import TEST_DEVICE_0_ID, TEST_DEVICE_1_ID -LOGGER = get_logger() +from common_tmtc.config.object_ids import TEST_DEVICE_0_ID, TEST_DEVICE_1_ID +LOGGER = get_console_logger() def service_3_hk_handling( diff --git a/tmtc/pus_tm/service_8_handling.py b/tmtc/common_tmtc/pus_tm/service_8_handling.py similarity index 100% rename from tmtc/pus_tm/service_8_handling.py rename to tmtc/common_tmtc/pus_tm/service_8_handling.py diff --git a/tmtc/tmtc_client_cli.py b/tmtc/tmtc_client_cli.py index 76d86fe..d22134a 100755 --- a/tmtc/tmtc_client_cli.py +++ b/tmtc/tmtc_client_cli.py @@ -28,9 +28,9 @@ limitations under the License. """ import sys -from config.hook_implementation import FsfwHookBase -from config.definitions import PUS_APID -from pus_tm.factory_hook import ccsds_tm_handler +from common_tmtc.config.hook_implementation import FsfwHookBase +from common_tmtc.config.definitions import PUS_APID +from common_tmtc.pus_tm.factory_hook import ccsds_tm_handler try: from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander, add_ccsds_handler from tmtccmd.ccsds.handler import CcsdsTmHandler diff --git a/tmtc/tmtc_client_gui.py b/tmtc/tmtc_client_gui.py index e2fb86c..cde216e 100644 --- a/tmtc/tmtc_client_gui.py +++ b/tmtc/tmtc_client_gui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -@brief TMTC Commander entry point for GUI mode. +@brief TMTC Commander entry point for command line mode. @details This client was developed by KSat for the SOURCE project to test the on-board software but has evolved into a more generic tool for satellite developers to perform TMTC (Telemetry and Telecommand) @@ -26,13 +26,29 @@ limitations under the License. @author R. Mueller """ -from config.hook_implementation import FsfwHookBase -from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander +import sys + +from common_tmtc.config.hook_implementation import FsfwHookBase +from common_tmtc.config.definitions import PUS_APID +from common_tmtc.pus_tm.factory_hook import ccsds_tm_handler +try: + from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander, add_ccsds_handler + from tmtccmd.ccsds.handler import CcsdsTmHandler +except ImportError as error: + run_tmtc_commander = None + initialize_tmtc_commander = None + print(error) + print("Python tmtccmd submodule could not be imported") + print("Install with \"cd tmtccmd && python3 -m pip install -e .\" for interactive installation") + sys.exit(0) def main(): hook_obj = FsfwHookBase() initialize_tmtc_commander(hook_object=hook_obj) + ccsds_handler = CcsdsTmHandler() + ccsds_handler.add_tm_handler(apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50) + add_ccsds_handler(ccsds_handler) run_tmtc_commander(use_gui=True, app_name="TMTC Commander FSFW")