From 7d85c494c04cfc4eb5b7cbcc29a44fc4cd3d377a Mon Sep 17 00:00:00 2001 From: Robin Mueller <robin.mueller.m@gmail.com> Date: Fri, 27 Nov 2020 23:15:16 +0100 Subject: [PATCH] version file added, printout improved --- config/obsw_config.py | 8 +++++++- ...obsw_com_config.py => tmtcc_com_config.py} | 0 ...sw_definitions.py => tmtcc_definitions.py} | 8 -------- config/tmtcc_version.py | 7 +++++++ core/tmtc_backend.py | 5 +++-- core/tmtc_client_core.py | 17 ++++++++++++----- core/tmtc_frontend.py | 19 ++++++++++--------- tc/obsw_tc_service20.py | 6 +++--- tm/obsw_tm_service_20.py | 5 ++++- tmtc_core | 2 +- utility/obsw_args_parser.py | 4 ++-- utility/obsw_file_transfer_helper.py | 2 +- 12 files changed, 50 insertions(+), 33 deletions(-) rename config/{obsw_com_config.py => tmtcc_com_config.py} (100%) rename config/{obsw_definitions.py => tmtcc_definitions.py} (63%) create mode 100644 config/tmtcc_version.py diff --git a/config/obsw_config.py b/config/obsw_config.py index dae9523..c84c17b 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -10,12 +10,17 @@ import struct import pprint import logging -from config.obsw_definitions import ModeList, ComInterfaces +from config.tmtcc_definitions import ModeList +from tmtc_core.tmtc_core_definitions import ComInterfaces """ Mission/Device specific information. """ +SW_NAME = "sputnik" +SW_VERSION = 1 +SW_SUBVERSION = 0 + # TODO: Automate / Autofill this file with the MIB parser # Object IDs @@ -114,6 +119,7 @@ G_TM_LISTENER = None G_COM_INTERFACE = None G_TMTC_PRINTER = None + # noinspection PyUnusedLocal def set_globals(args): global G_ETHERNET_RECV_ADDRESS, G_ETHERNET_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, \ diff --git a/config/obsw_com_config.py b/config/tmtcc_com_config.py similarity index 100% rename from config/obsw_com_config.py rename to config/tmtcc_com_config.py diff --git a/config/obsw_definitions.py b/config/tmtcc_definitions.py similarity index 63% rename from config/obsw_definitions.py rename to config/tmtcc_definitions.py index 3aff148..0b7748a 100644 --- a/config/obsw_definitions.py +++ b/config/tmtcc_definitions.py @@ -1,7 +1,4 @@ import enum -from typing import Tuple - -ethernetAddressT = Tuple[str, int] # Mode options, set by args parser @@ -17,8 +14,3 @@ class ModeList(enum.Enum): PromptMode = 32 -class ComInterfaces(enum.Enum): - Dummy = 0 - Serial = 1 - QEMU = 2 - Ethernet = 3 diff --git a/config/tmtcc_version.py b/config/tmtcc_version.py new file mode 100644 index 0000000..c8a46e6 --- /dev/null +++ b/config/tmtcc_version.py @@ -0,0 +1,7 @@ +""" +@brief Version file +""" + +SW_NAME = "tmtcc" +SW_VERSION = 1 +SW_SUBVERSION = 1 diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index 7898f65..56247d9 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -7,9 +7,10 @@ from collections import deque from typing import Tuple, Union from config import obsw_config as g -from config.obsw_definitions import ModeList, ComInterfaces +from config.tmtcc_definitions import ModeList from config.obsw_user_code import command_preparation_hook +from tmtc_core.tmtc_core_definitions import ComInterfaces from tmtc_core.utility.obsw_logger import get_logger from tmtc_core.tc.obsw_pus_tc_base import PusTcInfo from tmtc_core.sendreceive.obsw_single_command_sender_receiver import SingleCommandSenderReceiver @@ -21,7 +22,7 @@ from tmtc_core.utility.obsw_exit_handler import keyboard_interrupt_handler from tc.obsw_pus_tc_packer import ServiceQueuePacker, create_total_tc_queue from test.obsw_pus_service_test import run_selected_pus_tests -from config.obsw_com_config import set_communication_interface +from config.tmtcc_com_config import set_communication_interface from utility.obsw_binary_uploader import BinaryFileUploader LOGGER = get_logger() diff --git a/core/tmtc_client_core.py b/core/tmtc_client_core.py index 39a963c..88846e9 100755 --- a/core/tmtc_client_core.py +++ b/core/tmtc_client_core.py @@ -26,10 +26,10 @@ limitations under the License. Run this file with the -h flag to display options. """ import sys -from multiprocessing import Process from PyQt5.QtWidgets import QApplication +from config.tmtcc_version import SW_VERSION, SW_SUBVERSION from tmtc_core.utility.obsw_logger import set_tmtc_logger, get_logger from config.obsw_config import set_globals @@ -41,18 +41,25 @@ from utility.obsw_args_parser import parse_input_arguments LOGGER = get_logger() -def run_tmtc_client(use_gui: bool): +def run_tmtc_client(use_gui: bool, reduced_printout: bool = False): """ Main method, reads input arguments, sets global variables and start TMTC handler. """ + if not reduced_printout: + print("-- Python TMTC Commander --") + if use_gui: + print("-- GUI mode --") + else: + print("-- Command line mode --") + print("-- Software version v" + str(SW_VERSION) + "." + str(SW_SUBVERSION) + " --") set_tmtc_logger() - LOGGER.info("Starting TMTC Client") + LOGGER.info("Starting TMTC Client..") if not use_gui: - LOGGER.info("Parsing input arguments") + LOGGER.info("Parsing input arguments..") args = parse_input_arguments() - LOGGER.info("Setting global variables") + LOGGER.info("Setting global variables..") set_globals(args) LOGGER.info("Starting TMTC Handler..") diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py index fb9d88c..0461209 100644 --- a/core/tmtc_frontend.py +++ b/core/tmtc_frontend.py @@ -7,17 +7,18 @@ @manual @author R. Mueller, P. Scheurenbrand """ +import threading from multiprocessing import Process from PyQt5.QtWidgets import * from PyQt5.QtGui import QPixmap, QIcon -import sys + from core.tmtc_backend import TmTcHandler +from config import obsw_config + +from tmtc_core.tmtc_core_definitions import ComInterfaces from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand from tmtc_core.utility.obsw_logger import get_logger -from config import obsw_config -from config.obsw_definitions import ComInterfaces -import threading LOGGER = get_logger() @@ -29,7 +30,7 @@ TODO: Make it look nicer. Add SOURCE or KSat logo. class TmTcFrontend(QMainWindow): # TODO: this list should probably be inside an enum in the obsw_config.py - serviceList = [ 2, 3, 5, 8, 9, 17, 20, 200, "Dummy", "GPS0", "GPS1" ] # , "Error"] + serviceList = [2, 3, 5, 8, 9, 17, 20, 200, "Dummy", "GPS0", "GPS1"] # , "Error"] service_test_button: QPushButton single_command_button: QPushButton @@ -80,9 +81,9 @@ class TmTcFrontend(QMainWindow): LOGGER.info("send single command pressed") # parse the values from the table - #service = int(self.commandTable.item(0, 0).text()) - #subservice = int(self.commandTable.item(0, 1).text()) - #ssc = int(self.commandTable.item(0, 2).text()) + # service = int(self.commandTable.item(0, 0).text()) + # subservice = int(self.commandTable.item(0, 1).text()) + # ssc = int(self.commandTable.item(0, 2).text()) LOGGER.info("service: " + str(self.single_command_service) + ", subservice: " + str(self.single_command_sub_service) + @@ -171,7 +172,7 @@ class TmTcFrontend(QMainWindow): # TODO: set sensible min/max values spin_timeout.setSingleStep(0.1) spin_timeout.setMinimum(0.25) - spin_timeout.setMaximum(60)# + spin_timeout.setMaximum(60) # https://youtrack.jetbrains.com/issue/PY-22908 # Ignore those warnings for now. spin_timeout.valueChanged.connect(number_timeout) diff --git a/tc/obsw_tc_service20.py b/tc/obsw_tc_service20.py index b0dedf0..149fb9c 100644 --- a/tc/obsw_tc_service20.py +++ b/tc/obsw_tc_service20.py @@ -71,7 +71,7 @@ def pack_service20_test_into(tc_queue: Deque, called_externally: bool = False) - parameter_id = struct.pack(">I", parameterID0) type_and_matrix_data = pack_type_and_matrix_data(3, 14, 1, 1) parameter_data = struct.pack(">I", 42) - payload = object_id + parameter_id+ type_and_matrix_data + parameter_data + payload = object_id + parameter_id + type_and_matrix_data + parameter_data command = PusTelecommand(service=20, subservice=128, ssc=2010, app_data=payload) tc_queue.appendleft(command.pack_command_tuple()) @@ -87,7 +87,7 @@ def pack_service20_test_into(tc_queue: Deque, called_externally: bool = False) - parameter_id = struct.pack(">I", parameterID1) type_and_matrix_data = pack_type_and_matrix_data(4, 14, 1, 1) parameter_data = struct.pack(">i", -42) - payload = object_id + parameter_id+ type_and_matrix_data + parameter_data + payload = object_id + parameter_id + type_and_matrix_data + parameter_data command = PusTelecommand(service=20, subservice=128, ssc=2030, app_data=payload) tc_queue.appendleft(command.pack_command_tuple()) @@ -103,7 +103,7 @@ def pack_service20_test_into(tc_queue: Deque, called_externally: bool = False) - parameter_id = struct.pack(">I", parameterID2) type_and_matrix_data = pack_type_and_matrix_data(5, 1, 1, 1) parameter_data = struct.pack(">f", 4.2) - payload = object_id + parameter_id+ type_and_matrix_data + parameter_data + payload = object_id + parameter_id + type_and_matrix_data + parameter_data command = PusTelecommand(service=20, subservice=128, ssc=2050, app_data=payload) tc_queue.appendleft(command.pack_command_tuple()) diff --git a/tm/obsw_tm_service_20.py b/tm/obsw_tm_service_20.py index 48d4d63..f3c1bad 100644 --- a/tm/obsw_tm_service_20.py +++ b/tm/obsw_tm_service_20.py @@ -1,6 +1,9 @@ import struct from tmtc_core.tm.obsw_pus_tm_base import PusTelemetry, TmDictionaryKeys, PusTmInfoT +from tmtc_core.utility.obsw_logger import get_logger + +LOGGER = get_logger() class Service20TM(PusTelemetry): @@ -22,7 +25,7 @@ class Service20TM(PusTelemetry): if self.type_ptc == 5 and self.type_pfc == 1: self.param = struct.unpack('>f', self._tm_data[12:datasize])[0] else: - logger.info("Error when receiving Pus Service 20 TM: subservice is != 130, but 130 is \ + LOGGER.info("Error when receiving Pus Service 20 TM: subservice is != 130, but 130 is \ only known subservice") self.specify_packet_info("Functional Commanding Reply") diff --git a/tmtc_core b/tmtc_core index 2a12f36..db6aaef 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit 2a12f3621780fb5df5a9fcd30b936e8d1ad991c7 +Subproject commit db6aaef2824f19cfc3687ae63ec5480aeb0e4cb2 diff --git a/utility/obsw_args_parser.py b/utility/obsw_args_parser.py index 47f2018..1093ff7 100644 --- a/utility/obsw_args_parser.py +++ b/utility/obsw_args_parser.py @@ -32,8 +32,8 @@ def parse_input_arguments(): '--boardIP', help='Board IP. Default: Localhost 127.0.0.1', default="127.0.0.1") arg_parser.add_argument('-s', '--service', help='Service to test. Default: 17', default=17) arg_parser.add_argument( - '-l','--listener', help='Determine whether the listener mode will be active after ' - 'performing the operation', + '-l', '--listener', help='Determine whether the listener mode will be active ' + 'after performing the operation', action='store_false') arg_parser.add_argument( '-t', '--tm_timeout', type=float, help='TM Timeout when listening to verification sequence.' diff --git a/utility/obsw_file_transfer_helper.py b/utility/obsw_file_transfer_helper.py index c6efb90..52743ac 100644 --- a/utility/obsw_file_transfer_helper.py +++ b/utility/obsw_file_transfer_helper.py @@ -238,4 +238,4 @@ class FileTransferHelper: else: self.__number_of_finish_packets = 0 return - self.tc_queue.appendleft(last_command.pack_command_tuple()) \ No newline at end of file + self.tc_queue.appendleft(last_command.pack_command_tuple()) -- GitLab