2020-12-17 17:50:00 +01:00
|
|
|
#!/usr/bin/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
|
|
|
|
|
2021-04-24 23:17:36 +02:00
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
2020-12-17 17:50:00 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2021-06-21 17:30:37 +02:00
|
|
|
import sys
|
2022-03-07 11:07:54 +01:00
|
|
|
import traceback
|
2022-01-18 14:03:56 +01:00
|
|
|
|
2021-06-21 17:30:37 +02:00
|
|
|
try:
|
2022-04-05 15:19:46 +02:00
|
|
|
import tmtccmd.runner as tmtccmd
|
2022-04-06 11:43:17 +02:00
|
|
|
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
|
2022-04-04 22:32:15 +02:00
|
|
|
from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler
|
2022-04-05 00:55:17 +02:00
|
|
|
from tmtccmd.logging import init_console_logger
|
2021-06-21 17:30:37 +02:00
|
|
|
except ImportError as error:
|
|
|
|
run_tmtc_commander = None
|
|
|
|
initialize_tmtc_commander = None
|
2022-03-07 11:07:54 +01:00
|
|
|
tb = traceback.format_exc()
|
|
|
|
print(tb)
|
2022-01-18 14:03:56 +01:00
|
|
|
print("Python tmtccmd submodule could not be imported")
|
2021-10-06 18:19:23 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
import spacepackets
|
|
|
|
except ImportError as error:
|
|
|
|
print(error)
|
2022-01-18 14:03:56 +01:00
|
|
|
print("Python spacepackets module could not be imported")
|
2021-10-06 18:19:23 +02:00
|
|
|
print(
|
2022-01-18 14:03:56 +01:00
|
|
|
'Install with "cd spacepackets && python3 -m pip intall -e ." for interative installation'
|
2021-10-06 18:19:23 +02:00
|
|
|
)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
from config.hook_implementations import EiveHookObject
|
|
|
|
from config.version import __version__
|
|
|
|
from config.definitions import PUS_APID
|
2022-04-05 15:19:46 +02:00
|
|
|
from pus_tc.tc_packer_hook import pre_tc_send_cb
|
2021-10-06 18:19:23 +02:00
|
|
|
from pus_tm.factory_hook import ccsds_tm_handler
|
2020-12-17 17:50:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-01-18 14:03:56 +01:00
|
|
|
print(f"-- eive tmtc version {__version__} --")
|
|
|
|
print(f"-- spacepackets version {spacepackets.__version__} --")
|
2022-04-06 11:43:17 +02:00
|
|
|
tmtccmd.init_printout(False)
|
|
|
|
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
|
|
|
|
)
|
2021-06-21 17:30:37 +02:00
|
|
|
ccsds_handler = CcsdsTmHandler()
|
2022-04-06 11:43:17 +02:00
|
|
|
ccsds_handler.add_tm_handler(apid=PUS_APID, handler=apid_handler)
|
|
|
|
tmtccmd.setup(setup_args=setup_args)
|
2022-04-05 15:19:46 +02:00
|
|
|
tmtccmd.add_ccsds_handler(ccsds_handler)
|
|
|
|
tmtc_backend = tmtccmd.get_default_tmtc_backend(
|
2022-04-06 11:43:17 +02:00
|
|
|
setup_args=setup_args,
|
2022-04-05 17:05:11 +02:00
|
|
|
tm_handler=ccsds_handler,
|
2022-04-05 15:19:46 +02:00
|
|
|
)
|
|
|
|
tmtc_backend.set_pre_send_cb(callable=pre_tc_send_cb, user_args=None)
|
2022-04-06 11:43:17 +02:00
|
|
|
tmtccmd.run(tmtc_backend=tmtc_backend)
|
2020-12-17 17:50:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|