pre send CB works properly now

This commit is contained in:
Robin Mueller 2022-04-06 16:17:51 +02:00
parent fc2b50979e
commit 49f88a5b3d
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
9 changed files with 80 additions and 17 deletions

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="tmtccli-example" type="PythonConfigurationType" factoryName="Python" folderName="Example">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tmtccmd/examples" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtccmd/examples/tmtccli.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="tmtcgui-example" type="PythonConfigurationType" factoryName="Python" folderName="Example">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tmtccmd/examples" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtccmd/examples/tmtcgui.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -12,9 +12,7 @@ import argparse
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
)
from tmtccmd.config.globals import set_default_globals_pre_args_parsing
from tmtccmd.logging import get_console_logger
LOGGER = get_console_logger()

View File

@ -26,6 +26,7 @@ class EiveHookObject(TmTcHookBase):
def get_service_op_code_dictionary(self) -> ServiceOpCodeDictT:
from tmtccmd.config.globals import get_default_service_op_code_dict
service_op_code_dict = get_default_service_op_code_dict()
get_eive_service_op_code_dict(service_op_code_dict=service_op_code_dict)
return service_op_code_dict

View File

@ -1,15 +1,19 @@
"""Hook function which packs telecommands based on service and operation code string
"""
import logging
import os
from collections import deque
from typing import Union
from spacepackets.ecss import PusTelecommand
from tmtccmd.com_if.com_interface_base import CommunicationInterface
from tmtccmd.config.definitions import CoreServiceList
from tmtccmd.logging import get_console_logger
from tmtccmd.logging.pus import log_raw_pus_tc
from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.tc.service_5_event import pack_generic_service5_test_into
from tmtccmd.pus.service_17_test import pack_service_17_ping_command
from tmtccmd.logging import get_time_string
from pus_tc.service_200_mode import pack_service200_test_into
from pus_tc.devs.p60dock import pack_p60dock_test_into
@ -69,10 +73,19 @@ from config.object_ids import (
LOGGER = get_console_logger()
def pre_tc_send_cb(packet: bytes, user_args: any):
service = packet[7]
subservice = packet[8]
log_raw_pus_tc(packet=packet, srv_subservice=(service, subservice))
def pre_tc_send_cb(
packet: bytes,
com_if: CommunicationInterface,
pus_info: Union[PusTelecommand, any],
file_logger: logging.Logger,
):
log_raw_pus_tc(
packet=packet, srv_subservice=(pus_info.service, pus_info.subservice)
)
tc_info_string = f"Sent {pus_info}"
LOGGER.info(tc_info_string)
file_logger.info(f"{get_time_string(True)}: {tc_info_string}")
com_if.send(data=packet)
def pack_service_queue_user(

View File

@ -14,9 +14,7 @@ from tmtccmd.logging.pus import (
)
from tmtccmd.pus.service_17_test import Service17TMExtended
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 PrintFormats, FsfwTmTcPrinter

@ -1 +1 @@
Subproject commit dff986ca150099ce3d174cd627993c91981f09fc
Subproject commit 0501a26b6f347cf48e0875658ac4eaca8cc7d819

View File

@ -32,10 +32,14 @@ import traceback
try:
import tmtccmd.runner as tmtccmd
from tmtccmd.config import default_json_path, SetupArgs
from tmtccmd.config.args import create_default_args_parser, add_default_tmtccmd_args, \
parse_default_input_arguments
from tmtccmd.config.args import (
create_default_args_parser,
add_default_tmtccmd_args,
parse_default_input_arguments,
)
from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler
from tmtccmd.logging import init_console_logger
from tmtccmd.logging.pus import create_tmtc_logger
except ImportError as error:
run_tmtc_commander = None
initialize_tmtc_commander = None
@ -65,14 +69,15 @@ def main():
print(f"-- eive tmtc version {__version__} --")
print(f"-- spacepackets version {spacepackets.__version__} --")
tmtccmd.init_printout(False)
tmtc_file_logger = create_tmtc_logger()
hook_obj = EiveHookObject(json_cfg_path=default_json_path())
arg_parser = create_default_args_parser()
add_default_tmtccmd_args(arg_parser)
args = parse_default_input_arguments(arg_parser, hook_obj)
setup_args = SetupArgs(hook_obj=hook_obj, use_gui=False, apid=PUS_APID, cli_args=args)
apid_handler = ApidHandler(
cb=ccsds_tm_handler, queue_len=50, user_args=None
setup_args = SetupArgs(
hook_obj=hook_obj, use_gui=False, apid=PUS_APID, cli_args=args
)
apid_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None)
ccsds_handler = CcsdsTmHandler()
ccsds_handler.add_tm_handler(apid=PUS_APID, handler=apid_handler)
tmtccmd.setup(setup_args=setup_args)
@ -81,7 +86,7 @@ def main():
setup_args=setup_args,
tm_handler=ccsds_handler,
)
tmtc_backend.set_pre_send_cb(callable=pre_tc_send_cb, user_args=None)
tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger)
tmtccmd.run(tmtc_backend=tmtc_backend)

@ -1 +1 @@
Subproject commit aeb7b6ccb60765cb5f1f474aeb2459c60066689c
Subproject commit 6f88d6a11003962e552392f1eabf7f7ca73eac32