diff --git a/config/obsw_config.py b/config/obsw_config.py index dae952393a7474c21f1ef7c25b6245b226406b9f..c84c17ba927ee062ecadf962b66812beb4fa357b 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 3aff14867aa39318c7bfa8907fbcf511c7ea4ea8..0b7748ac2dff1f16e3edd69588af0185ab95bd65 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 0000000000000000000000000000000000000000..c8a46e69fd5d5588edc5819913367e2b82a6cdfa --- /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 7898f6561ccd6e986cdecdf408010ec962452a48..56247d9ac444b2bb61c38472073f0dbd216aba2a 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 39a963ce3be62ef47ac9eb292cefb01ab1928cd9..88846e9e92af1e4f06326eae3fb6ed8cecad7448 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 fb9d88cc1b8e2fe36f57203d26855951aa8ba2a4..04612093683b4262cb3a5a5f5a87f54bf13d6fc3 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 b0dedf027528d041fa0b87c3adb7aa26ed746abd..149fb9ccfd50af57a712961c30fad0245837041c 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 48d4d630d126251cbd80976cf87fffcc78401c8f..f3c1badb35b1682c2484765110c1d00a5f15c666 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 2a12f3621780fb5df5a9fcd30b936e8d1ad991c7..db6aaef2824f19cfc3687ae63ec5480aeb0e4cb2 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 47f2018ae2a2a64961d5f7e4e6b5eadc207e2ce3..1093ff7c3daf1a1b190b917372d5092bbb27ae38 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 c6efb90e7e15cf98b494e9c895f9137b88107c6f..52743acdacc40c1534f428ca29321a3938ccf45e 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())