From feb6de4c61a35f84b712123e18a9eff1859d1f9c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Mon, 6 Jul 2020 15:28:01 +0200 Subject: [PATCH] hook functions for global config and command preparations --- config/obsw_config.py | 2 ++ obsw_tmtc_client.py | 11 ++++++----- obsw_user_code.py | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 obsw_user_code.py diff --git a/config/obsw_config.py b/config/obsw_config.py index ad17aea..305b452 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -11,6 +11,7 @@ import struct import pprint from typing import Tuple import logging +from obsw_user_code import global_setup_hook """ Global service_type definitions @@ -166,4 +167,5 @@ def set_globals(args): G_PRINT_RAW_TM = args.rawDataPrint G_COM_PORT = args.com_port G_TM_TIMEOUT = args.tm_timeout + global_setup_hook() diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index b31983d..793aa9a 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -60,11 +60,15 @@ import unittest import logging import sys from collections import deque +from typing import Tuple, Union from test import obsw_pus_service_test from config import obsw_config as g from config.obsw_config import set_globals from tc.obsw_pus_tc_packer import PusTelecommand, create_total_tc_queue, pack_service_queue +from tc.obsw_pus_tc_frame_packer import pack_tc_frame +from obsw_user_code import command_preparation_hook +from tc.obsw_pus_tc_base import PusTcInfo from sendreceive.obsw_single_command_sender_receiver import SingleCommandSenderReceiver from sendreceive.obsw_sequential_sender_receiver import SequentialCommandSenderReceiver @@ -120,15 +124,12 @@ def main(): pass -def command_preparation(): +def command_preparation() -> Tuple[bytearray, Union[None, PusTcInfo]]: """ Prepare command for single command testing :return: """ - # Direct command which triggers an additional step reply and one completion reply - # Single Command Testing - command = PusTelecommand(service=17, subservice=1, ssc=21) - return command.pack_command_tuple() + return command_preparation_hook() class TmTcHandler: diff --git a/obsw_user_code.py b/obsw_user_code.py new file mode 100644 index 0000000..571ff27 --- /dev/null +++ b/obsw_user_code.py @@ -0,0 +1,17 @@ +""" +User defined code can be added here. +""" +from typing import Tuple, Union +from tc.obsw_pus_tc_base import PusTcInfo + +def command_preparation_hook() -> Tuple[bytearray, Union[None, PusTcInfo]]: + """ + Can be used to pack user-defined commands. + """ + pass + +def global_setup_hook(): + """ + Can be used to alter the global variables in a custom defined way. + """ + pass -- GitLab