Skip to content
Snippets Groups Projects
Forked from an inaccessible project.
tmtc_client_core.py 2.27 KiB
#!/usr/bin/python3
"""
@brief  This client was developed by KSat for the SOURCE project to test the on-board software.
@details
This client features multiple sender/receiver modes and has been designed
to be extensible and easy to use. This clien is based on the PUS standard for the format
of telecommands and telemetry. It can also send TMTC via different interfaces like the
serial interface (USB port) or ethernet interface.

@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

   http://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.

@manual
Run this file with the -h flag to display options.
"""
import sys
from multiprocessing import Process

from PyQt5.QtWidgets import QApplication

from tmtc_core.utility.obsw_logger import set_tmtc_logger, get_logger

from config.obsw_config import set_globals
import config.obsw_config as g
from core.tmtc_backend import TmTcHandler
from core.tmtc_frontend import TmTcFrontend
from utility.obsw_args_parser import parse_input_arguments

LOGGER = get_logger()


def run_tmtc_client(use_gui: bool):
    """
    Main method, reads input arguments, sets global variables and start TMTC handler.
    """
    set_tmtc_logger()
    LOGGER.info("Starting TMTC Client")

    if not use_gui:
        LOGGER.info("Parsing input arguments")
        args = parse_input_arguments()

        LOGGER.info("Setting global variables")
        set_globals(args)

    LOGGER.info("Starting TMTC Handler..")

    if not use_gui:
        # The global variables are set by the argument parser.
        tmtc_handler = TmTcHandler(g.G_COM_IF, g.G_MODE_ID)
        tmtc_handler.set_one_shot_or_loop_handling(g.G_LISTENER_AFTER_OP)
        tmtc_handler.initialize()
        tmtc_handler.start()
    else:
        app = QApplication(["TMTC Commander"])
        tmtc_gui = TmTcFrontend()
        tmtc_gui.start_ui()

        sys.exit(app.exec_())