From 1bc38ea4b507ac0e395c52d0b142ad598bb0817c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Feb 2023 15:00:31 +0100 Subject: [PATCH] better debug facilities for TM debugging --- tmtcc.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tmtcc.py b/tmtcc.py index da1ed2d..7cafaaf 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -98,6 +98,7 @@ from eive_tmtc.pus_tm.factory_hook import pus_factory_hook from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure _LOGGER = APP_LOGGER +_LOG_LEVEL = logging.INFO # Put rotating file logger parameters here for quick changes ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE @@ -179,7 +180,14 @@ class PusHandler(SpecificApidHandlerBase): class UnknownApidHandler(GenericApidHandlerBase): def handle_tm(self, apid: int, packet: bytes, _user_args: any): - _LOGGER.warning(f"Packet with unknwon APID {apid} detected: {packet}") + _LOGGER.warning( + f"Packet with unknown APID {apid} detected: {packet.hex(sep=',')}" + ) + + +class CustomCcsdsTmHandler(CcsdsTmHandler): + def user_hook(self, apid: int, packet: bytes): + _LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}") class CfdpInCcsdsWrapper(SpecificApidHandlerBase): @@ -398,7 +406,7 @@ def setup_tmtc_handlers( verificator, _LOGGER, printer.file_logger ) pus_handler = PusHandler(verification_wrapper, printer, raw_logger) - ccsds_handler = CcsdsTmHandler(generic_handler=UnknownApidHandler(None)) + ccsds_handler = CustomCcsdsTmHandler(generic_handler=UnknownApidHandler(None)) ccsds_handler.add_apid_handler(pus_handler) ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper) seq_count_provider = PusFileSeqCountProvider() @@ -433,6 +441,8 @@ def main(): print(f"-- eive tmtc v{__version__} --") print(f"-- spacepackets v{spacepackets.__version__} --") add_colorlog_console_logger(_LOGGER) + # TODO: -V CLI argument to enable this? + _LOGGER.setLevel(_LOG_LEVEL) try: setup_wrapper = setup_params() except KeyboardInterrupt as e: