From 052af605fd76199c90a0facd278ec833d6268c5e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 17 May 2022 11:04:34 +0200 Subject: [PATCH 1/4] first version of continous operation --- tmtccmd | 2 +- tmtcloop.py | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100755 tmtcloop.py diff --git a/tmtccmd b/tmtccmd index d503c8b..35f96d1 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit d503c8b8a95d107f482880a8ba692fdd8d46adbc +Subproject commit 35f96d10fe59413a374261940219784b080f39fc diff --git a/tmtcloop.py b/tmtcloop.py new file mode 100755 index 0000000..982d8d1 --- /dev/null +++ b/tmtcloop.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +""" +@brief TMTC Commander entry point for command line mode. +@details +This client was developed by KSat for the SOURCE project to test the on-board software but +has evolved into a more generic tool for satellite developers to perform TMTC (Telemetry and Telecommand) +handling and testing via different communication interfaces. Currently, only the PUS standard is +implemented as a packet standard. + +Run this file with the -h flag to display options. + +@license +Copyright 2020 KSat e.V. Stuttgart + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +@author R. Mueller +""" +import sys +import traceback + +try: + import tmtccmd.runner as tmtccmd + from tmtccmd.config import default_json_path, SetupArgs, CoreGlobalIds + from tmtccmd.config.definitions import CoreModeList + 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 get_console_logger + from tmtccmd.logging.pus import create_tmtc_logger +except ImportError as error: + run_tmtc_commander = None + initialize_tmtc_commander = None + tb = traceback.format_exc() + print(tb) + print("Python tmtccmd submodule could not be imported") + sys.exit(1) + +try: + import spacepackets +except ImportError as error: + print(error) + print("Python spacepackets module could not be imported") + print( + 'Install with "cd spacepackets && python3 -m pip intall -e ." for interative installation' + ) + sys.exit(1) + +from config.hook_implementations import EiveHookObject +from config.version import __version__ +from config.definitions import PUS_APID +from pus_tc.tc_packer_hook import pre_tc_send_cb +from pus_tm.factory_hook import ccsds_tm_handler + +from tmtccmd.core.globals_manager import ( + get_global +) + +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) + ccsds_handler = CcsdsTmHandler() + ccsds_handler.add_tm_handler(apid=PUS_APID, handler=apid_handler) + tmtccmd.setup(setup_args=setup_args) + tmtccmd.add_ccsds_handler(ccsds_handler) + tmtc_backend = tmtccmd.create_default_tmtc_backend( + setup_args=setup_args, + tm_handler=ccsds_handler, + ) + tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger) + + tmtc_backend.set_mode(CoreModeList.CONTINOUS_MODE) + + get_console_logger().info("Disabling console logger for continous operation") + get_console_logger().disabled = True; + + tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend) + tmtccmd.performOperation(tmtc_backend=tmtc_backend) + + #remove cmdline args so that we can reuse code + sys.argv = sys.argv[:1] + + while True: + 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 + ) + tmtccmd.setup(setup_args=setup_args) + tmtc_backend.set_mode(CoreModeList.CONTINOUS_MODE) + + tmtccmd.performOperation(tmtc_backend=tmtc_backend) + + +if __name__ == "__main__": + main() From 619790e01af24cd96dceb3bb1e7e448f54a64f76 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 17 May 2022 11:33:40 +0200 Subject: [PATCH 2/4] spelling --- tmtccmd | 2 +- tmtcloop.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tmtccmd b/tmtccmd index 35f96d1..6229632 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 35f96d10fe59413a374261940219784b080f39fc +Subproject commit 6229632de63a5d9eb3bb7d9971d3f3120fe46ddb diff --git a/tmtcloop.py b/tmtcloop.py index 982d8d1..aaf07aa 100755 --- a/tmtcloop.py +++ b/tmtcloop.py @@ -92,9 +92,9 @@ def main(): ) tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger) - tmtc_backend.set_mode(CoreModeList.CONTINOUS_MODE) + tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) - get_console_logger().info("Disabling console logger for continous operation") + get_console_logger().info("Disabling console logger for continuous operation") get_console_logger().disabled = True; tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend) @@ -109,7 +109,7 @@ def main(): hook_obj=hook_obj, use_gui=False, apid=PUS_APID, cli_args=args ) tmtccmd.setup(setup_args=setup_args) - tmtc_backend.set_mode(CoreModeList.CONTINOUS_MODE) + tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) tmtccmd.performOperation(tmtc_backend=tmtc_backend) From 85ed307b58ea50bf088a7ca897141b2b1cb6b221 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 May 2022 14:11:20 +0200 Subject: [PATCH 3/4] bump tmtccmd again --- tmtccmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtccmd b/tmtccmd index 14559c1..0895aae 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 14559c1dfbe682b8727acc22132fd590c767d05b +Subproject commit 0895aae63414cdca4a16c53028fe72401c1b50e0 From 8455490fe1536f4ed75d5fc1de77e148c5c87521 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 May 2022 14:34:05 +0200 Subject: [PATCH 4/4] form improvements --- tmtcloop.py | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/tmtcloop.py b/tmtcloop.py index aaf07aa..d2cfb5b 100755 --- a/tmtcloop.py +++ b/tmtcloop.py @@ -1,31 +1,5 @@ #!/usr/bin/env python3 -""" -@brief TMTC Commander entry point for command line mode. -@details -This client was developed by KSat for the SOURCE project to test the on-board software but -has evolved into a more generic tool for satellite developers to perform TMTC (Telemetry and Telecommand) -handling and testing via different communication interfaces. Currently, only the PUS standard is -implemented as a packet standard. - -Run this file with the -h flag to display options. - -@license -Copyright 2020 KSat e.V. Stuttgart - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -@author R. Mueller -""" +"""EIVE TMTC Commander""" import sys import traceback @@ -59,22 +33,14 @@ except ImportError as error: ) sys.exit(1) -from config.hook_implementations import EiveHookObject -from config.version import __version__ from config.definitions import PUS_APID from pus_tc.tc_packer_hook import pre_tc_send_cb from pus_tm.factory_hook import ccsds_tm_handler +from tmtcc import tmtcc_pre_args -from tmtccmd.core.globals_manager import ( - get_global -) 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()) + hook_obj = tmtcc_pre_args() arg_parser = create_default_args_parser() add_default_tmtccmd_args(arg_parser) args = parse_default_input_arguments(arg_parser, hook_obj) @@ -90,17 +56,18 @@ def main(): setup_args=setup_args, tm_handler=ccsds_handler, ) + tmtc_file_logger = create_tmtc_logger() tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger) tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) get_console_logger().info("Disabling console logger for continuous operation") - get_console_logger().disabled = True; + get_console_logger().disabled = True tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend) tmtccmd.performOperation(tmtc_backend=tmtc_backend) - #remove cmdline args so that we can reuse code + # remove cmdline args so that we can reuse code sys.argv = sys.argv[:1] while True: