fsfw-example-hosted/tmtc/tmtccli.py

69 lines
2.3 KiB
Python
Raw Normal View History

2021-06-11 12:53:35 +02:00
#!/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
"""
2021-06-17 18:44:24 +02:00
import sys
2021-06-18 16:28:53 +02:00
2021-10-13 12:09:21 +02:00
from spacepackets.log import set_custom_console_logger_name
2021-07-14 00:24:09 +02:00
from common_tmtc.config.hook_implementation import FsfwHookBase
from common_tmtc.config.definitions import PUS_APID
from common_tmtc.pus_tm.factory_hook import ccsds_tm_handler
2021-12-14 16:00:46 +01:00
2021-06-11 12:53:35 +02:00
try:
2021-12-14 16:00:46 +01:00
from tmtccmd.runner import (
run_tmtc_commander,
initialize_tmtc_commander,
add_ccsds_handler,
)
2021-06-18 16:28:53 +02:00
from tmtccmd.ccsds.handler import CcsdsTmHandler
2021-10-13 12:09:21 +02:00
from tmtccmd.utility.logger import TMTC_LOGGER_NAME
2021-06-17 18:55:57 +02:00
except ImportError as error:
2021-06-11 12:53:35 +02:00
run_tmtc_commander = None
initialize_tmtc_commander = None
2021-06-17 18:55:57 +02:00
print(error)
print("Python tmtccmd submodule could not be imported")
2021-12-14 16:00:46 +01:00
print(
'Install with "cd tmtccmd && python3 -m pip install -e ." for interactive installation'
)
2021-06-17 18:44:24 +02:00
sys.exit(0)
2021-06-11 12:53:35 +02:00
def main():
hook_obj = FsfwHookBase()
initialize_tmtc_commander(hook_object=hook_obj)
2021-06-18 16:44:50 +02:00
ccsds_handler = CcsdsTmHandler()
2021-12-14 16:00:46 +01:00
ccsds_handler.add_tm_handler(
apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50
)
2021-06-18 16:28:53 +02:00
add_ccsds_handler(ccsds_handler)
2021-10-13 12:09:21 +02:00
set_custom_console_logger_name(TMTC_LOGGER_NAME)
2021-06-11 12:53:35 +02:00
run_tmtc_commander(use_gui=False, app_name="TMTC Commander FSFW")
if __name__ == "__main__":
main()