From d241101d887e2910834a0a7e43edf58270191696 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 17:30:37 +0200 Subject: [PATCH] updated tmtc --- .gitignore | 6 +++++- config/definitions.py | 3 +++ config/globals_config.py | 5 +++-- config/hook_implementations.py | 3 ++- pus_tm/factory_hook.py | 28 +++++++++++++++++++--------- tmtc_client_cli.py | 17 ++++++++++++++++- tmtccmd | 2 +- 7 files changed, 49 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index ab65048..50cba5f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,8 @@ log /Lib /Scripts -/pyvenv.cfg \ No newline at end of file +/pyvenv.cfg +/bin +/lib +/lib64 +/share diff --git a/config/definitions.py b/config/definitions.py index 0b134c2..75b7b21 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -7,6 +7,9 @@ import enum +PUS_APID = 0x65 + + class CustomServiceList(enum.Enum): TEST_DEVICE = "test", P60DOCK = "p60dock" diff --git a/config/globals_config.py b/config/globals_config.py index c1199c6..b8274bb 100644 --- a/config/globals_config.py +++ b/config/globals_config.py @@ -9,7 +9,7 @@ import argparse # All globals can be added here and will be part of a globals dictionary. -from config.definitions import CustomServiceList +from config.definitions import CustomServiceList, PUS_APID from config.custom_mode_op import CustomModeList from tmtccmd.config.definitions import CoreComInterfaces from tmtccmd.config.globals import set_default_globals_pre_args_parsing, \ @@ -25,7 +25,8 @@ class CustomGlobalIds(enum.Enum): def set_globals_pre_args_parsing(gui: bool = False): - set_default_globals_pre_args_parsing(gui=gui, apid=0x65, com_if_id=CoreComInterfaces.TCPIP_UDP.value) + set_default_globals_pre_args_parsing( + gui=gui, apid=PUS_APID, com_if_id=CoreComInterfaces.TCPIP_UDP.value) def add_globals_post_args_parsing(args: argparse.Namespace, json_cfg_path: str): diff --git a/config/hook_implementations.py b/config/hook_implementations.py index e55836f..3b0e2ac 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -97,7 +97,8 @@ class EiveHookObject(TmTcHookBase): Union[CommunicationInterface, None]: from tmtccmd.config.com_if import create_communication_interface_default return create_communication_interface_default( - com_if_key=com_if_key, tmtc_printer=tmtc_printer, json_cfg_path=self.get_json_config_file_path() + com_if_key=com_if_key, tmtc_printer=tmtc_printer, + json_cfg_path=self.get_json_config_file_path() ) def perform_mode_operation(self, tmtc_backend: TmTcHandler, mode: int): diff --git a/pus_tm/factory_hook.py b/pus_tm/factory_hook.py index 1d10153..ab2b264 100644 --- a/pus_tm/factory_hook.py +++ b/pus_tm/factory_hook.py @@ -11,22 +11,32 @@ from tmtccmd.pus_tm.service_1_verification import Service1TM from tmtccmd.pus_tm.service_3_housekeeping import Service3TM from tmtccmd.pus_tm.service_5_event import Service5TM from tmtccmd.pus_tm.service_17_test import Service17TM +from tmtccmd.utility.tmtc_printer import TmTcPrinter + +from config.definitions import PUS_APID LOGGER = get_logger() -def tm_user_factory_hook(raw_tm_packet: bytearray) -> PusTelemetry: +def ccsds_tm_handler(apid: int, raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter) -> None: + if apid == PUS_APID: + pus_factory_hook(raw_tm_packet=raw_tm_packet, tmtc_printer=tmtc_printer) + + +def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter): service_type = raw_tm_packet[7] + tm_packet = None if service_type == 1: - return Service1TM(raw_tm_packet) + tm_packet = Service1TM(raw_tm_packet) if service_type == 3: - return Service3TM(raw_tm_packet) + tm_packet = Service3TM(raw_tm_packet) if service_type == 5: - return Service5TM(raw_tm_packet) + tm_packet = Service5TM(raw_tm_packet) if service_type == 8: - service_8_tm = Service8TM(raw_tm_packet) - return Service8TM(raw_tm_packet) + tm_packet = Service8TM(raw_tm_packet) if service_type == 17: - return Service17TM(raw_tm_packet) - LOGGER.info("The service " + str(service_type) + " is not implemented in Telemetry Factory") - return PusTelemetry(raw_tm_packet) + tm_packet = Service17TM(raw_tm_packet) + if tm_packet is None: + LOGGER.info(f'The service {service_type} is not implemented in Telemetry Factory') + tm_packet = PusTelemetry(raw_tm_packet) + tmtc_printer.print_telemetry(packet=tm_packet) diff --git a/tmtc_client_cli.py b/tmtc_client_cli.py index c481101..e31b5c4 100644 --- a/tmtc_client_cli.py +++ b/tmtc_client_cli.py @@ -26,13 +26,28 @@ limitations under the License. @author R. Mueller """ -from tmtccmd.runner import initialize_tmtc_commander, run_tmtc_commander +import sys + from config.hook_implementations import EiveHookObject +from config.definitions import PUS_APID +from pus_tm.factory_hook import ccsds_tm_handler +try: + from tmtccmd.runner import initialize_tmtc_commander, run_tmtc_commander + 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 = EiveHookObject() 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) run_tmtc_commander(False) diff --git a/tmtccmd b/tmtccmd index 9415eac..ec23093 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 9415eac9eeb17dffed31f3a7a1ef849902eeb5c1 +Subproject commit ec23093bff4c70ab0044f1bb049c64a2376ec927