diff --git a/common.py b/common.py index 36a36ba..a3b5907 100644 --- a/common.py +++ b/common.py @@ -3,6 +3,7 @@ import sys from tmtccmd.com_if import ComInterface from tmtccmd.logging import get_current_time_string +from tmtccmd.pus.pus_11_tc_sched import Subservices as Pus11Subservices from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter @@ -20,7 +21,7 @@ except ImportError as error: print("Python tmtccmd module could not be imported. Make sure it is installed") sys.exit(1) -from spacepackets.ecss import PusVerificator +from spacepackets.ecss import PusVerificator, PusTelecommand from common_tmtc.pus_tc.pus_11_tc_sched import pack_service_11_commands from common_tmtc.pus_tc.pus_17_test import pack_service_17_commands @@ -37,7 +38,8 @@ from tmtccmd.tc import ( FeedWrapper, TcProcedureType, QueueEntryHelper, - TcQueueEntryType, SendCbParams, + TcQueueEntryType, + SendCbParams, ) from tmtccmd.tc.pus_5_event import pack_generic_service_5_test_into from tmtccmd.tm import SpecificApidHandlerBase, CcsdsTmHandler @@ -122,10 +124,27 @@ class TcHandler(TcHandlerBase): if params.entry.is_tc: if params.entry.entry_type == TcQueueEntryType.PUS_TC: pus_tc_wrapper = params.entry.to_pus_tc_entry() + # TODO: All of this stuff should be done during queue insertion time + # This requires the queue helper to be optionally able to perform TC + # post-processing via a callback or something similar. Then an API can be + # added which is also able to pack time tagged TCs and stamping both TCs pus_tc_wrapper.pus_tc.seq_count = ( self.seq_count_provider.get_and_increment() ) pus_tc_wrapper.pus_tc.apid = EXAMPLE_APID + if ( + pus_tc_wrapper.pus_tc.service == 11 + and pus_tc_wrapper.pus_tc.subservice == Pus11Subservices.TC_INSERT + ): + try: + pus_tc = PusTelecommand.unpack( + pus_tc_wrapper.pus_tc.app_data[4:] + ) + self.pus_verificator.add_tc(pus_tc) + except ValueError as e: + LOGGER.warning( + f"Attempt of unpacking time tagged TC failed with exception {e}" + ) # Add TC after Sequence Count stamping self.pus_verificator.add_tc(pus_tc_wrapper.pus_tc) raw_tc = pus_tc_wrapper.pus_tc.pack() @@ -147,9 +166,7 @@ class TcHandler(TcHandlerBase): def setup_params(hook_obj: TmTcCfgHookBase) -> SetupWrapper: print(f"-- eive TMTC Commander --") - print( - f"-- spacepackets v{spacepackets.__version__} --" - ) + print(f"-- spacepackets v{spacepackets.__version__} --") params = SetupParams() parser_wrapper = ArgParserWrapper(hook_obj) parser_wrapper.parse()