From 2b7a75e32b1a5f851be928cf0d62dbc863909159 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 22:32:15 +0200 Subject: [PATCH] temporary fix for tmtc printer overhaul --- config/hook_implementations.py | 18 ++---------------- config/object_ids.py | 2 +- config/retvals.py | 2 +- pus_tm/event_handler.py | 2 +- pus_tm/factory_hook.py | 13 +++++++------ tmtccli.py | 15 ++++++--------- tmtccmd | 2 +- 7 files changed, 19 insertions(+), 35 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 3915be8..4e0790c 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -13,7 +13,7 @@ from tmtccmd.pus.obj_id import ObjectIdDictT from tmtccmd.com_if.com_interface_base import CommunicationInterface from tmtccmd.core.backend import TmTcHandler from tmtccmd.config.hook import TmTcHookBase -from tmtccmd.utility.tmtc_printer import TmTcPrinter +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter from tmtccmd.config.globals import OpCodeDictKeys from config.definitions import CustomServiceList @@ -50,13 +50,12 @@ class EiveHookObject(TmTcHookBase): ) def assign_communication_interface( - self, com_if_key: str, tmtc_printer: TmTcPrinter + self, com_if_key: str ) -> 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(), space_packet_ids=(0x0865,), ) @@ -88,19 +87,6 @@ class EiveHookObject(TmTcHookBase): object_id=object_id, action_id=action_id, custom_data=custom_data ) - @staticmethod - def handle_service_3_housekeeping( - object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base - ) -> HkReplyUnpacked: - from pus_tm.hk_handling import handle_user_hk_packet - - return handle_user_hk_packet( - object_id=object_id, - set_id=set_id, - hk_data=hk_data, - service3_packet=service3_packet, - ) - @staticmethod def handle_service_5_event( object_id: bytes, event_id: int, param_1: int, param_2: int diff --git a/config/object_ids.py b/config/object_ids.py index 08ecc6c..bbeb7d0 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -5,7 +5,7 @@ """ import os.path from tmtccmd.pus.obj_id import ObjectIdDictT -from tmtccmd.utility.fsfw import parse_fsfw_objects_csv +from tmtccmd.fsfw import parse_fsfw_objects_csv from tmtccmd.utility.logger import get_console_logger LOGGER = get_console_logger() diff --git a/config/retvals.py b/config/retvals.py index ab1a78d..b80218d 100644 --- a/config/retvals.py +++ b/config/retvals.py @@ -1,5 +1,5 @@ import os -from tmtccmd.utility.fsfw import parse_fsfw_returnvalues_csv, RetvalDictT +from tmtccmd.fsfw import parse_fsfw_returnvalues_csv, RetvalDictT from tmtccmd.utility.logger import get_console_logger DEFAULT_RETVAL_CSV_NAME = "config/returnvalues.csv" diff --git a/pus_tm/event_handler.py b/pus_tm/event_handler.py index 8d64db5..1455ce8 100644 --- a/pus_tm/event_handler.py +++ b/pus_tm/event_handler.py @@ -2,7 +2,7 @@ import os.path from config.object_ids import get_object_ids from tmtccmd.utility.logger import get_console_logger -from tmtccmd.utility.fsfw import parse_fsfw_events_csv, EventDictT, EventInfo +from tmtccmd.fsfw import parse_fsfw_events_csv, EventDictT, EventInfo LOGGER = get_console_logger() DEFAULT_EVENTS_CSV_PATH = "config/events.csv" diff --git a/pus_tm/factory_hook.py b/pus_tm/factory_hook.py index 4532bd1..20d7a75 100644 --- a/pus_tm/factory_hook.py +++ b/pus_tm/factory_hook.py @@ -13,7 +13,7 @@ from tmtccmd.tm.service_3_fsfw_housekeeping import Service3FsfwTm from tmtccmd.tm.service_20_fsfw_parameters import Service20FsfwTm from tmtccmd.tm.service_5_event import Service5Tm from tmtccmd.tm.service_200_fsfw_mode import Service200FsfwTm -from tmtccmd.utility.tmtc_printer import TmTcPrinter, PrintFormats +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter, PrintFormats from config.definitions import PUS_APID @@ -21,13 +21,13 @@ LOGGER = get_console_logger() def ccsds_tm_handler( - apid: int, raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter + apid: int, raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter ) -> 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): +def pus_factory_hook(raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter): if len(raw_tm_packet) < 8: LOGGER.warning("Detected packet shorter than 8 bytes!") return @@ -56,9 +56,10 @@ def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter): ) tm_packet = PusTelemetry.unpack(raw_telemetry=raw_tm_packet) tm_packet.print_source_data(PrintFormats.HEX) - tmtc_printer.print_telemetry( - packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False - ) + LOGGER.info(f"Received packet with service {service_type}") + # tmtc_printer.print_telemetry( + # packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False + # ) except ValueError: # TODO: Log faulty packet LOGGER.warning("Invalid packet format detected") diff --git a/tmtccli.py b/tmtccli.py index 9561eb9..9cf2831 100755 --- a/tmtccli.py +++ b/tmtccli.py @@ -26,6 +26,7 @@ limitations under the License. @author R. Mueller """ +import logging import sys import traceback @@ -35,8 +36,8 @@ try: run_tmtc_commander, add_ccsds_handler, ) - from tmtccmd.ccsds.handler import CcsdsTmHandler - from tmtccmd.utility.logger import TMTC_LOGGER_NAME + from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler + from tmtccmd.utility.logger import init_console_logger except ImportError as error: run_tmtc_commander = None initialize_tmtc_commander = None @@ -47,7 +48,6 @@ except ImportError as error: try: import spacepackets - from spacepackets.log import set_custom_console_logger_name except ImportError as error: print(error) print("Python spacepackets module could not be imported") @@ -63,17 +63,14 @@ from pus_tm.factory_hook import ccsds_tm_handler def main(): - from pus_tm.event_handler import handle_event_packet - hook_obj = EiveHookObject() print(f"-- eive tmtc version {__version__} --") print(f"-- spacepackets version {spacepackets.__version__} --") - set_custom_console_logger_name(logger_name=TMTC_LOGGER_NAME) 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 - ) + init_console_logger(logging.DEBUG) + pus_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None) + ccsds_handler.add_tm_handler(apid=PUS_APID, handler=pus_handler) add_ccsds_handler(ccsds_handler) run_tmtc_commander(False) diff --git a/tmtccmd b/tmtccmd index 3cda2df..946c128 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 3cda2df79d2b3eb29855a29ff33df8e4d6f18ae1 +Subproject commit 946c128e111ea460034d8bf3a3d3a8f81bccb0c5