better debug facilities for TM debugging

This commit is contained in:
Robin Müller 2023-02-20 15:00:31 +01:00
parent 37fcdb9a60
commit 1bc38ea4b5
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -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 from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure
_LOGGER = APP_LOGGER _LOGGER = APP_LOGGER
_LOG_LEVEL = logging.INFO
# Put rotating file logger parameters here for quick changes # Put rotating file logger parameters here for quick changes
ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE
@ -179,7 +180,14 @@ class PusHandler(SpecificApidHandlerBase):
class UnknownApidHandler(GenericApidHandlerBase): class UnknownApidHandler(GenericApidHandlerBase):
def handle_tm(self, apid: int, packet: bytes, _user_args: any): 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): class CfdpInCcsdsWrapper(SpecificApidHandlerBase):
@ -398,7 +406,7 @@ def setup_tmtc_handlers(
verificator, _LOGGER, printer.file_logger verificator, _LOGGER, printer.file_logger
) )
pus_handler = PusHandler(verification_wrapper, printer, raw_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(pus_handler)
ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper) ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper)
seq_count_provider = PusFileSeqCountProvider() seq_count_provider = PusFileSeqCountProvider()
@ -433,6 +441,8 @@ def main():
print(f"-- eive tmtc v{__version__} --") print(f"-- eive tmtc v{__version__} --")
print(f"-- spacepackets v{spacepackets.__version__} --") print(f"-- spacepackets v{spacepackets.__version__} --")
add_colorlog_console_logger(_LOGGER) add_colorlog_console_logger(_LOGGER)
# TODO: -V CLI argument to enable this?
_LOGGER.setLevel(_LOG_LEVEL)
try: try:
setup_wrapper = setup_params() setup_wrapper = setup_params()
except KeyboardInterrupt as e: except KeyboardInterrupt as e: