diff --git a/config/tmtcc_user_code.py b/config/tmtcc_user_code.py index 1620a3f77b377a3edc625c353cff7270e6c99bd7..fb5e6fb72b7a0d2c5515ed05a5554e41a3863e3f 100644 --- a/config/tmtcc_user_code.py +++ b/config/tmtcc_user_code.py @@ -2,7 +2,7 @@ User defined code can be added here. """ from typing import Union, Tuple -from tmtc_core.tc.tmtcc_pus_tc_base import PusTcInfo +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTcInfo from tmtc_core.tmtc_core_definitions import ComInterfaces from enum import Enum @@ -26,7 +26,7 @@ def command_preparation_hook() -> Tuple[bytearray, Union[None, PusTcInfo]]: def prepare_robins_commands(): - from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand + from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand command = PusTelecommand(service=17, subservice=1, ssc=20) return command.pack_command_tuple() diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index de830bfc45f74b9a092c3f2ae3c957073a559504..5551cfd8302f5eabc8f6802394468ed94b77d027 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -9,10 +9,11 @@ from typing import Tuple, Union from config import tmtcc_config as g from config.tmtcc_definitions import ModeList from config.tmtcc_user_code import command_preparation_hook +from pus_tc.tmtcc_tc_packer_hook import create_total_tc_queue from tmtc_core.tmtc_core_definitions import ComInterfaces from tmtc_core.utility.obsw_logger import get_logger -from tmtc_core.tc.tmtcc_pus_tc_base import PusTcInfo +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTcInfo from tmtc_core.sendreceive.obsw_single_command_sender_receiver import SingleCommandSenderReceiver from tmtc_core.sendreceive.obsw_sequential_sender_receiver import SequentialCommandSenderReceiver from tmtc_core.sendreceive.obsw_tm_listener import TmListener @@ -20,7 +21,7 @@ from tmtc_core.comIF.obsw_com_interface import CommunicationInterface from tmtc_core.utility.obsw_tmtc_printer import TmTcPrinter from tmtc_core.utility.obsw_exit_handler import keyboard_interrupt_handler -from tc.obsw_pus_tc_packer import ServiceQueuePacker, create_total_tc_queue +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import ServiceQueuePacker from test.obsw_pus_service_test import run_selected_pus_tests from config.tmtcc_com_config import set_communication_interface from utility.tmtcc_binary_uploader import BinaryFileUploader @@ -148,7 +149,7 @@ class TmTcHandler: service_queue = deque() service_queue_packer = ServiceQueuePacker() op_code = g.G_OP_CODE - service_queue_packer.pack_service_queue( + service_queue_packer.pack_service_queue_core( service=g.G_SERVICE, service_queue=service_queue, op_code=op_code) if not self.communication_interface.valid: return diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py index c867c918ca567ef5ca9180e642a184ddf83dfec4..3c0c96e911557a9bf1e4c6c03f6d2d48d603b430 100644 --- a/core/tmtc_frontend.py +++ b/core/tmtc_frontend.py @@ -17,7 +17,7 @@ from core.tmtc_backend import TmTcHandler from config import tmtcc_config from tmtc_core.tmtc_core_definitions import ComInterfaces -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() @@ -348,12 +348,12 @@ def checkbox_short_display_mode(state: int): def number_timeout(value: float): - LOGGER.info("tm timeout changed to: " + str(value)) + LOGGER.info("pus_tm timeout changed to: " + str(value)) tmtcc_config.G_TM_TIMEOUT = value def number_timeout_factor(value: float): - LOGGER.info("tm timeout factor changed to: " + str(value)) + LOGGER.info("pus_tm timeout factor changed to: " + str(value)) tmtcc_config.G_TC_SEND_TIMEOUT_FACTOR = value diff --git a/tc/__init__.py b/pus_tc/__init__.py similarity index 100% rename from tc/__init__.py rename to pus_tc/__init__.py diff --git a/tc/obsw_tc_gps.py b/pus_tc/obsw_tc_gps.py similarity index 93% rename from tc/obsw_tc_gps.py rename to pus_tc/obsw_tc_gps.py index f97b50f4427e274bc6284b27aa3b684a2b101e0c..cb98a13af4ef3671d1826ae9f1f2b1d551f9e387 100644 --- a/tc/obsw_tc_gps.py +++ b/pus_tc/obsw_tc_gps.py @@ -6,12 +6,14 @@ @date 02.05.2020 """ -from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand -from tc.obsw_tc_service2 import pack_mode_data +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from pus_tc.obsw_tc_service2 import pack_mode_data import config.tmtcc_config as g + def pack_gps_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: if object_id == g.GPS0_DEVICE_ID: gps_string = "GPS0" diff --git a/tc/obsw_tc_service2.py b/pus_tc/obsw_tc_service2.py similarity index 94% rename from tc/obsw_tc_service2.py rename to pus_tc/obsw_tc_service2.py index 281498e89607b9ec2027199433847b687a117de6..761d701d7dc6814784ece602fb0952bf073c9939 100644 --- a/tc/obsw_tc_service2.py +++ b/pus_tc/obsw_tc_service2.py @@ -8,8 +8,8 @@ import struct import config.tmtcc_config as g -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand, Deque -from tc.obsw_tc_service200 import pack_mode_data +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand, Deque +from pus_tc.tmtcc_tc_mode_service200 import pack_mode_data def pack_service2_test_into(tc_queue: Deque, called_externally: bool = False) -> Deque: diff --git a/tc/obsw_tc_service3.py b/pus_tc/obsw_tc_service3.py similarity index 96% rename from tc/obsw_tc_service3.py rename to pus_tc/obsw_tc_service3.py index 3e873ac6e9e4718a0c76cdcc88a7a2a8dfef76e9..5a8906aab9f5c007438e07d851f3c9bfeb0335fb 100644 --- a/tc/obsw_tc_service3.py +++ b/pus_tc/obsw_tc_service3.py @@ -7,7 +7,7 @@ """ import struct from typing import Deque, Union -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand import config.tmtcc_config as g diff --git a/tc/obsw_tc_service8.py b/pus_tc/obsw_tc_service8.py similarity index 93% rename from tc/obsw_tc_service8.py rename to pus_tc/obsw_tc_service8.py index db8687496219a777a9dd45c742b4cb8b9ef3958a..62193ce55c89e6271cdc42aa8d808b5089fd9d28 100644 --- a/tc/obsw_tc_service8.py +++ b/pus_tc/obsw_tc_service8.py @@ -8,8 +8,8 @@ from typing import Deque import config.tmtcc_config as g -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand -from tc.obsw_tc_service200 import pack_mode_data +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from pus_tc.tmtcc_tc_mode_service200 import pack_mode_data def pack_service8_test_into(tc_queue: Deque, called_externally: bool = False) -> Deque: diff --git a/tc/obsw_tc_service9.py b/pus_tc/obsw_tc_service9.py similarity index 93% rename from tc/obsw_tc_service9.py rename to pus_tc/obsw_tc_service9.py index 7970b0e5215faba74de4de94156f4a6236f16e29..03c31040fe692142a4ade21a0eb73b689a551185 100644 --- a/tc/obsw_tc_service9.py +++ b/pus_tc/obsw_tc_service9.py @@ -7,7 +7,8 @@ """ from datetime import datetime -from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() diff --git a/tc/obsw_image_handler.py b/pus_tc/tmtcc_image_handler.py similarity index 92% rename from tc/obsw_image_handler.py rename to pus_tc/tmtcc_image_handler.py index b8baeee5c077775e6515f96b5b39a867f14e51f4..9c22ffe853aec98f832d1bbced98d111db9f89fa 100644 --- a/tc/obsw_image_handler.py +++ b/pus_tc/tmtcc_image_handler.py @@ -1,8 +1,8 @@ from typing import Union -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand, Deque -from tmtc_core.tc.tmtcc_tc_service8 import make_action_id -from tc.obsw_tc_service20 import pack_boolean_parameter_setting +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand, Deque +from tmtc_core.pus_tc.tmtcc_pus_tc_service8 import make_action_id +from pus_tc.tmtcc_tc_service20 import pack_boolean_parameter_setting from tmtc_core.utility.obsw_logger import get_logger from config.tmtcc_config import SW_IMAGE_HANDLER_ID diff --git a/tc/obsw_tc_service5_17.py b/pus_tc/tmtcc_pus_service17.py similarity index 51% rename from tc/obsw_tc_service5_17.py rename to pus_tc/tmtcc_pus_service17.py index b602a294224af3f3f48fb8bb9af1732644813420..1b174c36269a73a1e1f4b30c3e21ac83137c7abe 100644 --- a/tc/obsw_tc_service5_17.py +++ b/pus_tc/tmtcc_pus_service17.py @@ -1,48 +1,13 @@ -# -*- coding: utf-8 -*- -""" -@file obsw_tc_service5_17.py -@brief PUS Service 5: Event Service - PUS Service 17: Test Service -@author R. Mueller -@date 02.05.2020 -""" -import config.tmtcc_config as g -from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT, PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_service17 import pack_service17_ping_command -def pack_service5_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Service 5")) - # invalid subservice - tc_queue.appendleft(("print", "Testing Service 5: Invalid subservice")) - command = PusTelecommand(service=5, subservice=1, ssc=500) - tc_queue.appendleft(command.pack_command_tuple()) - # disable events - tc_queue.appendleft(("print", "Testing Service 5: Disable event")) - command = PusTelecommand(service=5, subservice=6, ssc=500) - tc_queue.appendleft(command.pack_command_tuple()) - # trigger event - tc_queue.appendleft(("print", "Testing Service 5: Trigger event")) - command = PusTelecommand(service=17, subservice=128, ssc=510) - tc_queue.appendleft(command.pack_command_tuple()) - # enable event - tc_queue.appendleft(("print", "Testing Service 5: Enable event")) - command = PusTelecommand(service=5, subservice=5, ssc=520) - tc_queue.appendleft(command.pack_command_tuple()) - # trigger event - tc_queue.appendleft(("print", "Testing Service 5: Trigger another event")) - command = PusTelecommand(service=17, subservice=128, ssc=530) - tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("export", "log/tmtc_log_service5.txt")) - return tc_queue - - -def pack_service17_test_into(tc_queue: TcQueueT, op_code: int = 0) -> TcQueueT: +def pack_service17_test_into(tc_queue: TcQueueT, op_code: int = 0): if op_code == 0: tc_queue.appendleft(("print", "Testing Service 17")) # ping test tc_queue.appendleft(("print", "Testing Service 17: Ping Test")) - command = PusTelecommand(service=17, subservice=1, ssc=1700) - tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(pack_service17_ping_command(ssc=1700).pack_command_tuple()) # enable event tc_queue.appendleft(("print", "Testing Service 17: Enable Event")) command = PusTelecommand(service=5, subservice=5, ssc=52) @@ -77,4 +42,4 @@ def pack_enable_periodic_print_packet(tc_queue: TcQueueT, enable: bool, ssc: int def pack_trigger_exception_packet(tc_queue: TcQueueT, ssc: int): tc_queue.appendleft(("print", "Triggering software exception")) command = PusTelecommand(service=17, subservice=150, ssc=ssc) - tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(command.pack_command_tuple()) \ No newline at end of file diff --git a/tc/obsw_pus_tc_frame_packer.py b/pus_tc/tmtcc_pus_tc_frame_packer.py similarity index 96% rename from tc/obsw_pus_tc_frame_packer.py rename to pus_tc/tmtcc_pus_tc_frame_packer.py index c437ecf9ddca350e32533332a145d393f7d9599f..7830b47acb50ffb675fd7d956b9e13a201a431b5 100644 --- a/tc/obsw_pus_tc_frame_packer.py +++ b/pus_tc/tmtcc_pus_tc_frame_packer.py @@ -2,7 +2,7 @@ @brief Helper module to pack telecommand frames. """ from typing import List, Tuple -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand, PusTcInfo +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand, PusTcInfo from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() diff --git a/tc/obsw_tc_utility.py b/pus_tc/tmtcc_pus_tc_utility.py similarity index 75% rename from tc/obsw_tc_utility.py rename to pus_tc/tmtcc_pus_tc_utility.py index c5f09ad22d9f55aea1d123bac9dbbb0937ffb2e1..9f410961e3c8450f5778b665a6a9fc30a588710e 100644 --- a/tc/obsw_tc_utility.py +++ b/pus_tc/tmtcc_pus_tc_utility.py @@ -1,7 +1,7 @@ from typing import Union -from tmtc_core.tc.tmtcc_pus_tc_base import TcQueueT -from tmtc_core.tc.tmtcc_tc_service8 import generate_action_command +from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_service8 import generate_action_command from config.tmtcc_config import LED_TASK_ID diff --git a/tc/obsw_tc_core.py b/pus_tc/tmtcc_tc_core.py similarity index 92% rename from tc/obsw_tc_core.py rename to pus_tc/tmtcc_tc_core.py index b0cdb3edd1cc6030150ad2922c74e8a85b45b1a8..dc418378519a50506d152fb9dec47cd4e0566dc3 100644 --- a/tc/obsw_tc_core.py +++ b/pus_tc/tmtcc_tc_core.py @@ -1,8 +1,8 @@ from typing import Deque from config.tmtcc_config import CORE_CONTROLLER_ID -from tmtc_core.tc.tmtcc_tc_service8 import make_action_id -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_service8 import make_action_id +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand def pack_core_command(tc_queue: Deque, op_code, ssc: int = 0): diff --git a/tc/obsw_tc_service200.py b/pus_tc/tmtcc_tc_mode_service200.py similarity index 90% rename from tc/obsw_tc_service200.py rename to pus_tc/tmtcc_tc_mode_service200.py index c2686d4b2598866b0b4101b523e33b0af23bd6e0..88cc58202a972bbc9f761182d7cec6bd77d24e73 100644 --- a/tc/obsw_tc_service200.py +++ b/pus_tc/tmtcc_tc_mode_service200.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ -@file obsw_tc_service200.py +@file tmtcc_tc_mode_service200.py @brief PUS Service 200: PUS custom service 200: Mode commanding @author R. Mueller @date 02.05.2020 """ -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand -from tc.obsw_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT import config.tmtcc_config as g import struct diff --git a/pus_tc/tmtcc_tc_packer_hook.py b/pus_tc/tmtcc_tc_packer_hook.py new file mode 100644 index 0000000000000000000000000000000000000000..3baa62a34b7942835ad26ee1fcd39ad7b878b457 --- /dev/null +++ b/pus_tc/tmtcc_tc_packer_hook.py @@ -0,0 +1,113 @@ +import os +from collections import deque +from typing import Union + +import config.tmtcc_config as g +from tmtc_core.utility.obsw_logger import get_logger +from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT, PusTelecommand + +from pus_tc.obsw_tc_service2 import pack_service2_test_into +from pus_tc.obsw_tc_service3 import pack_service3_test_into +from pus_tc.obsw_tc_service8 import pack_service8_test_into +from pus_tc.obsw_tc_service9 import pack_service9_test_into +from pus_tc.tmtcc_tc_service23_sdcard import pack_service23_commands_into +from pus_tc.tmtcc_tc_service20 import pack_service20_test_into +from pus_tc.tmtcc_pus_tc_utility import pack_utility_command +from pus_tc.tmtcc_tc_mode_service200 import pack_mode_data, pack_service200_test_into +from pus_tc.tmtcc_tc_service5 import pack_service5_test_into +from pus_tc.tmtcc_pus_service17 import pack_service17_test_into +from pus_tc.tmtcc_image_handler import generate_img_handler_packet +from pus_tc.obsw_tc_gps import pack_gps_test_into +from pus_tc.tmtcc_tc_core import pack_core_command + + +LOGGER = get_logger() + +def pack_service_queue(service: Union[int, str], op_code: int, service_queue: TcQueueT): + if service == 2: + return pack_service2_test_into(service_queue) + if service == 3: + return pack_service3_test_into(service_queue, op_code) + if service == 5: + return pack_service5_test_into(service_queue) + if service == 8: + return pack_service8_test_into(service_queue) + if service == 9: + return pack_service9_test_into(service_queue) + if service == 17: + return pack_service17_test_into(service_queue, op_code) + if service == 20: + return pack_service20_test_into(service_queue) + if service == 23 or service.lower() == "sd": + return pack_service23_commands_into(service_queue, op_code) + if service == 200: + return pack_service200_test_into(service_queue) + if service.lower() == "dummy": + return pack_dummy_device_test_into(service_queue) + if service.lower() == "img": + return generate_img_handler_packet(service_queue, op_code) + if service.lower() == "core": + return pack_core_command(service_queue, op_code) + if service.lower() == "led": + return pack_utility_command(service_queue, op_code) + if service.lower() == "gps0": + # Object ID: GPS Device + object_id = g.GPS0_DEVICE_ID + return pack_gps_test_into(object_id, service_queue) + if service.lower() == "gps1": + # Object ID: GPS Device + object_id = g.GPS1_DEVICE_ID + return pack_gps_test_into(object_id, service_queue) + if service.lower() == "Error": + return pack_error_testing_into(service_queue) + LOGGER.warning("Invalid Service !") + +# TODO: a way to select certain services would be nice (by passing a dict or array maybe) +def create_total_tc_queue() -> TcQueueT: + if not os.path.exists("log"): + os.mkdir("log") + tc_queue = deque() + tc_queue = pack_service2_test_into(tc_queue) + tc_queue = pack_service3_test_into(tc_queue) + tc_queue = pack_service5_test_into(tc_queue) + tc_queue = pack_service8_test_into(tc_queue) + tc_queue = pack_service9_test_into(tc_queue) + tc_queue = pack_service17_test_into(tc_queue) + tc_queue = pack_service20_test_into(tc_queue) + tc_queue = pack_service200_test_into(tc_queue) + tc_queue = pack_dummy_device_test_into(tc_queue) + object_id = g.GPS0_DEVICE_ID + tc_queue = pack_gps_test_into(object_id, tc_queue) + return tc_queue + + + + + +def pack_dummy_device_test_into(tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft(("print", "Testing Dummy Device")) + # Object ID: Dummy Device + object_id = g.DUMMY_DEVICE_ID + # Set On Mode + tc_queue.appendleft(("print", "Testing Service Dummy: Set On")) + mode_data = pack_mode_data(object_id, 1, 0) + command = PusTelecommand(service=200, subservice=1, ssc=1, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + # Test Service 2 commands + tc_queue.appendleft(("print", "Testing Service Dummy: Service 2")) + pack_service2_test_into(tc_queue, True) + # Test Service 8 + tc_queue.appendleft(("print", "Testing Service Dummy: Service 8")) + pack_service8_test_into(tc_queue, True) + tc_queue.appendleft(("export", "log/tmtc_log_service_dummy.txt")) + return tc_queue + + +def pack_error_testing_into(tc_queue: TcQueueT) -> TcQueueT: + # a lot of events + command = PusTelecommand(service=17, subservice=129, ssc=2010) + tc_queue.appendleft(command.pack_command_tuple()) + # a lot of ping testing + command = PusTelecommand(service=17, subservice=130, ssc=2020) + tc_queue.appendleft(command.pack_command_tuple()) + return tc_queue \ No newline at end of file diff --git a/tc/obsw_tc_service20.py b/pus_tc/tmtcc_tc_service20.py similarity index 96% rename from tc/obsw_tc_service20.py rename to pus_tc/tmtcc_tc_service20.py index 9cca1ae29b4b7e615f8d9dbb41f03dfca67959ef..58c7af3372287554403ae221389f8d732e01b9a4 100644 --- a/tc/obsw_tc_service20.py +++ b/pus_tc/tmtcc_tc_service20.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -@file obsw_tc_service20.py +@file tmtcc_tc_service20.py @brief PUS Service 20: Parameter management. @author J. Gerhards @date 30.06.2020 @@ -9,9 +9,9 @@ import struct from typing import Deque import config.tmtcc_config as g -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand, TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand, TcQueueT from tmtc_core.utility.obsw_logger import get_logger -from tc.obsw_tc_service200 import pack_mode_data +from pus_tc.tmtcc_tc_mode_service200 import pack_mode_data LOGGER = get_logger() diff --git a/tc/obsw_tc_service23_sdcard.py b/pus_tc/tmtcc_tc_service23_sdcard.py similarity index 99% rename from tc/obsw_tc_service23_sdcard.py rename to pus_tc/tmtcc_tc_service23_sdcard.py index 379d24dca42ddff857894024f40b180600dfc74f..25ac7f6b6b92f46a42f68203ab9b2d4f13a2c185 100644 --- a/tc/obsw_tc_service23_sdcard.py +++ b/pus_tc/tmtcc_tc_service23_sdcard.py @@ -7,8 +7,9 @@ Created: 21.01.2020 07:48 import config.tmtcc_config as g from typing import Deque, Union -from tc.obsw_pus_tc_packer import PusTelecommand, TcQueueT -from tmtc_core.tc.tmtcc_tc_service8 import make_action_id +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_service8 import make_action_id from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() diff --git a/pus_tc/tmtcc_tc_service5.py b/pus_tc/tmtcc_tc_service5.py new file mode 100644 index 0000000000000000000000000000000000000000..9f04908a240c5b14f593e9ded637f7c5f7118c9e --- /dev/null +++ b/pus_tc/tmtcc_tc_service5.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +""" +@file tmtcc_tc_service5.py +@brief PUS Service 5: Event Service + PUS Service 17: Test Service +@author R. Mueller +@date 02.05.2020 +""" +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.pus_tc.tmtcc_pus_tc_service17 import pack_service17_ping_command + + +def pack_service5_test_into(tc_queue: TcQueueT): + tc_queue.appendleft(("print", "Testing Service 5")) + # invalid subservice + tc_queue.appendleft(("print", "Testing Service 5: Invalid subservice")) + command = PusTelecommand(service=5, subservice=1, ssc=500) + tc_queue.appendleft(command.pack_command_tuple()) + # disable events + tc_queue.appendleft(("print", "Testing Service 5: Disable event")) + command = PusTelecommand(service=5, subservice=6, ssc=500) + tc_queue.appendleft(command.pack_command_tuple()) + # trigger event + tc_queue.appendleft(("print", "Testing Service 5: Trigger event")) + command = PusTelecommand(service=17, subservice=128, ssc=510) + tc_queue.appendleft(command.pack_command_tuple()) + # enable event + tc_queue.appendleft(("print", "Testing Service 5: Enable event")) + command = PusTelecommand(service=5, subservice=5, ssc=520) + tc_queue.appendleft(command.pack_command_tuple()) + # trigger event + tc_queue.appendleft(("print", "Testing Service 5: Trigger another event")) + command = PusTelecommand(service=17, subservice=128, ssc=530) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(("export", "log/tmtc_log_service5.txt")) + + diff --git a/tm/__init__.py b/pus_tm/__init__.py similarity index 100% rename from tm/__init__.py rename to pus_tm/__init__.py diff --git a/tm/obsw_pus_tm_factory_hook.py b/pus_tm/obsw_pus_tm_factory_hook.py similarity index 92% rename from tm/obsw_pus_tm_factory_hook.py rename to pus_tm/obsw_pus_tm_factory_hook.py index f30b4fa2ae29150c0bec13b1ac3f73bf92aaef5b..8b2c647dca385f18cf9b536e78a4cf4726aaed9c 100644 --- a/tm/obsw_pus_tm_factory_hook.py +++ b/pus_tm/obsw_pus_tm_factory_hook.py @@ -1,13 +1,13 @@ import struct -from tmtc_core.tm.tmtcc_pus_tm_base import PusTelemetry +from tmtc_core.pus_tm.tmtcc_pus_tm_base import PusTelemetry from tmtc_core.utility.obsw_logger import get_logger -from tmtc_core.tm.tmtcc_tm_service_1 import Service1TM -from tm.obsw_tm_service_3 import Service3TM -from tmtc_core.tm.tmtcc_tm_service_5 import Service5TM -from tm.obsw_tm_service_20 import Service20TM -from tm.obsw_tm_service_23 import Service23TM +from tmtc_core.pus_tm.tmtcc_tm_service_1 import Service1TM +from pus_tm.obsw_tm_service_3 import Service3TM +from tmtc_core.pus_tm.tmtcc_tm_service_5 import Service5TM +from pus_tm.obsw_tm_service_20 import Service20TM +from pus_tm.obsw_tm_service_23 import Service23TM LOGGER = get_logger() diff --git a/tm/obsw_tm_service_20.py b/pus_tm/obsw_tm_service_20.py similarity index 96% rename from tm/obsw_tm_service_20.py rename to pus_tm/obsw_tm_service_20.py index 4a3f6fe340c48d0e1ffee36f2c6f280fa49b7278..aa0b661955b306095d9404d81b4707dc312da8d1 100644 --- a/tm/obsw_tm_service_20.py +++ b/pus_tm/obsw_tm_service_20.py @@ -1,6 +1,6 @@ import struct -from tmtc_core.tm.tmtcc_pus_tm_base import PusTelemetry, TmDictionaryKeys, PusTmInfoT +from tmtc_core.pus_tm.tmtcc_pus_tm_base import PusTelemetry, TmDictionaryKeys, PusTmInfoT from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() diff --git a/tm/obsw_tm_service_23.py b/pus_tm/obsw_tm_service_23.py similarity index 98% rename from tm/obsw_tm_service_23.py rename to pus_tm/obsw_tm_service_23.py index 6a34463673dd88b687e8729254a50c12d53cc107..1e92544f0904388fd76c6c1d20c8620a53f070bc 100644 --- a/tm/obsw_tm_service_23.py +++ b/pus_tm/obsw_tm_service_23.py @@ -1,6 +1,6 @@ import struct -from tmtc_core.tm.tmtcc_pus_tm_base import PusTelemetry +from tmtc_core.pus_tm.tmtcc_pus_tm_base import PusTelemetry from tmtc_core.utility.obsw_logger import get_logger LOGGER = get_logger() diff --git a/tm/obsw_tm_service_3.py b/pus_tm/obsw_tm_service_3.py similarity index 97% rename from tm/obsw_tm_service_3.py rename to pus_tm/obsw_tm_service_3.py index 749af44391d94acc6490ecf2d28b435a134fd1fa..b5270d1b742abcfcb58c52498c2b21b88e34dd13 100644 --- a/tm/obsw_tm_service_3.py +++ b/pus_tm/obsw_tm_service_3.py @@ -6,7 +6,7 @@ Description: Deserialize Housekeeping TM Author: R. Mueller """ -from tmtc_core.tm.tmtcc_pus_tm_base import PusTelemetry +from tmtc_core.pus_tm.tmtcc_pus_tm_base import PusTelemetry from typing import Type from tmtc_core.utility.obsw_logger import get_logger import struct diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py deleted file mode 100644 index efa958faab1af4f0b9fdab4d49c1c569891e8cee..0000000000000000000000000000000000000000 --- a/tc/obsw_pus_tc_packer.py +++ /dev/null @@ -1,124 +0,0 @@ -# -*- coding: utf-8 -*- -""" -@file obsw_tc_packer.py -@brief Packs the TC queue for specific G_SERVICE or device testing -@details -Contains the sevice packet which can pack specific service queues (hardcoded for now) -@author R. Mueller -@date 01.11.2019 -""" -import os - -from tmtc_core.tc.tmtcc_pus_tc_base import PusTelecommand, TcQueueT -from tc.obsw_tc_service2 import pack_service2_test_into -from tc.obsw_tc_service3 import pack_service3_test_into -from tc.obsw_tc_service8 import pack_service8_test_into -from tc.obsw_tc_service9 import pack_service9_test_into -from tc.obsw_tc_service23_sdcard import pack_service23_commands_into -from tc.obsw_tc_service20 import pack_service20_test_into -from tc.obsw_tc_utility import pack_utility_command -from tc.obsw_tc_service200 import pack_mode_data, pack_service200_test_into -from tc.obsw_tc_service5_17 import pack_service5_test_into, pack_service17_test_into -from tc.obsw_image_handler import generate_img_handler_packet -from tc.obsw_tc_gps import pack_gps_test_into -from tc.obsw_tc_core import pack_core_command - -from tmtc_core.utility.obsw_logger import get_logger -import config.tmtcc_config as g -from collections import deque -from typing import Union - -LOGGER = get_logger() - - -class ServiceQueuePacker: - def __init__(self): - pass - - @staticmethod - def pack_service_queue(service: Union[int, str], op_code: int, service_queue: TcQueueT): - if service == 2: - return pack_service2_test_into(service_queue) - if service == 3: - return pack_service3_test_into(service_queue, op_code) - if service == 5: - return pack_service5_test_into(service_queue) - if service == 8: - return pack_service8_test_into(service_queue) - if service == 9: - return pack_service9_test_into(service_queue) - if service == 17: - return pack_service17_test_into(service_queue, op_code) - if service == 20: - return pack_service20_test_into(service_queue) - if service == 23 or service.lower() == "sd": - return pack_service23_commands_into(service_queue, op_code) - if service == 200: - return pack_service200_test_into(service_queue) - if service.lower() == "dummy": - return pack_dummy_device_test_into(service_queue) - if service.lower() == "img": - return generate_img_handler_packet(service_queue, op_code) - if service.lower() == "core": - return pack_core_command(service_queue, op_code) - if service.lower() == "led": - return pack_utility_command(service_queue, op_code) - if service.lower() == "gps0": - # Object ID: GPS Device - object_id = g.GPS0_DEVICE_ID - return pack_gps_test_into(object_id, service_queue) - if service.lower() == "gps1": - # Object ID: GPS Device - object_id = g.GPS1_DEVICE_ID - return pack_gps_test_into(object_id, service_queue) - if service.lower() == "Error": - return pack_error_testing_into(service_queue) - LOGGER.warning("Invalid Service !") - - -# TODO: a way to select certain services would be nice (by passing a dict or array maybe) -def create_total_tc_queue() -> TcQueueT: - if not os.path.exists("log"): - os.mkdir("log") - tc_queue = deque() - tc_queue = pack_service2_test_into(tc_queue) - tc_queue = pack_service3_test_into(tc_queue) - tc_queue = pack_service5_test_into(tc_queue) - tc_queue = pack_service8_test_into(tc_queue) - tc_queue = pack_service9_test_into(tc_queue) - tc_queue = pack_service17_test_into(tc_queue) - tc_queue = pack_service20_test_into(tc_queue) - tc_queue = pack_service200_test_into(tc_queue) - tc_queue = pack_dummy_device_test_into(tc_queue) - object_id = g.GPS0_DEVICE_ID - tc_queue = pack_gps_test_into(object_id, tc_queue) - return tc_queue - - -def pack_dummy_device_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Dummy Device")) - # Object ID: Dummy Device - object_id = g.DUMMY_DEVICE_ID - # Set On Mode - tc_queue.appendleft(("print", "Testing Service Dummy: Set On")) - mode_data = pack_mode_data(object_id, 1, 0) - command = PusTelecommand(service=200, subservice=1, ssc=1, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) - # Test Service 2 commands - tc_queue.appendleft(("print", "Testing Service Dummy: Service 2")) - pack_service2_test_into(tc_queue, True) - # Test Service 8 - tc_queue.appendleft(("print", "Testing Service Dummy: Service 8")) - pack_service8_test_into(tc_queue, True) - tc_queue.appendleft(("export", "log/tmtc_log_service_dummy.txt")) - return tc_queue - - -def pack_error_testing_into(tc_queue: TcQueueT) -> TcQueueT: - # a lot of events - command = PusTelecommand(service=17, subservice=129, ssc=2010) - tc_queue.appendleft(command.pack_command_tuple()) - # a lot of ping testing - command = PusTelecommand(service=17, subservice=130, ssc=2020) - tc_queue.appendleft(command.pack_command_tuple()) - return tc_queue diff --git a/test/obsw_module_test.py b/test/obsw_module_test.py index 138b00a3004167705fe69f55ac3de9e98ff3229f..905074a6492bb3211d02ea1b1ee2e148649aa39e 100644 --- a/test/obsw_module_test.py +++ b/test/obsw_module_test.py @@ -45,11 +45,11 @@ from collections import deque from typing import Deque from config import tmtcc_config as g -from tc.obsw_pus_tc_packer import pack_dummy_device_test_into -from tmtc_core.tc.tmtcc_pus_tc_base import PusTcInfoQueueT, TcDictionaryKeys -from tmtc_core.tm.tmtcc_tm_service_1 import PusPacketInfoService1T -from tmtc_core.tm.tmtcc_pus_tm_base import TmDictionaryKeys -from tmtc_core.tm.tmtcc_pus_tm_factory import PusTmInfoQueueT, PusTmInfoT +from pus_tc.tmtcc_tc_packer_hook import pack_dummy_device_test_into +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTcInfoQueueT, TcDictionaryKeys +from tmtc_core.pus_tm.tmtcc_tm_service_1 import PusPacketInfoService1T +from tmtc_core.pus_tm.tmtcc_pus_tm_base import TmDictionaryKeys +from tmtc_core.pus_tm.tmtcc_pus_tm_factory import PusTmInfoQueueT, PusTmInfoT from tmtc_core.sendreceive.obsw_multiple_commands_sender_receiver import MultipleCommandSenderReceiver from tmtc_core.utility.obsw_logger import get_logger @@ -80,12 +80,12 @@ class TestService(unittest.TestCase): :return: """ cls._displayMode = "long" - # wait intervals between tc send bursts. - # Example: [2,4] sends to send 2 tc from queue and wait, then sends another 2 and wait again + # wait intervals between pus_tc send bursts. + # Example: [2,4] sends to send 2 pus_tc from queue and wait, then sends another 2 and wait again cls.wait_intervals = [] cls.wait_time = 5.0 cls.print_tc = True - # default wait time between tc send bursts + # default wait time between pus_tc send bursts cls.test_queue = deque() # Extremely ugly solution so that we can use the Python Unit Test Framework @@ -127,7 +127,7 @@ class TestService(unittest.TestCase): TODO: Maybe we should instantiate this once in the main and then reuse it instead of calling the constructor over and over again. If done so we need a setter for: wait_time, wait_intervals, printTm, - tc_timeout_factor and the tc.queue. Furthermore, changing parameters should + tc_timeout_factor and the pus_tc.queue. Furthermore, changing parameters should only be allowed as long as the commander/receiver is not running by checking a flag :return: """ @@ -199,7 +199,7 @@ class TestService(unittest.TestCase): def scan_for_respective_tc(self, current_tm_info: PusTmInfoT): """ - this function looks whether the tc verification SSC matched + this function looks whether the pus_tc verification SSC matched a source sequence count of the sent TM """ current_subservice = current_tm_info[TmDictionaryKeys.SUBSERVICE] diff --git a/test/obsw_pus_service_test.py b/test/obsw_pus_service_test.py index 4b5be68f7403e45ccbc305ca07083ff163881ae9..80c3ba3760039eb04b808957061561b0575fcc75 100644 --- a/test/obsw_pus_service_test.py +++ b/test/obsw_pus_service_test.py @@ -9,10 +9,9 @@ import unittest from typing import Deque from test.obsw_module_test import TestService, PusTmInfoQueueT, TmDictionaryKeys, AssertionDictKeys -from tmtc_core.tc.tmtcc_pus_tc_base import PusTcInfoQueueT -from tc.obsw_pus_tc_packer import pack_service17_test_into, pack_service5_test_into, \ - pack_service2_test_into, pack_service8_test_into, pack_service200_test_into, \ - pack_service20_test_into +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTcInfoQueueT +from pus_tc.tmtcc_tc_packer_hook import pack_service17_test_into, pack_service5_test_into, \ + pack_service2_test_into, pack_service8_test_into, pack_service200_test_into import config.tmtcc_config as g from tmtc_core.utility.obsw_logger import get_logger @@ -184,8 +183,8 @@ class TestService17(TestService): def _analyse_tm_tc_info(self, tm_info_queue: PusTmInfoQueueT, tc_info_queue: PusTcInfoQueueT): assertion_dict = super()._analyse_tm_tc_info(tm_info_queue=tm_info_queue, tc_info_queue=tc_info_queue) - # add anything elsee other than tc verification counter - # and ssc that is needed for tm analysis + # add anything elsee other than pus_tc verification counter + # and ssc that is needed for pus_tm analysis return assertion_dict def analyse_tc_info(self, tc_info_queue): @@ -257,8 +256,8 @@ class TestService200(TestService): def _analyse_tm_tc_info(self, tm_info_queue: PusTmInfoQueueT, tc_info_queue: PusTcInfoQueueT): assertion_dict = super()._analyse_tm_tc_info(tm_info_queue=tm_info_queue, tc_info_queue=tc_info_queue) - # add anything else other than tc verification counter - # and ssc that is needed for tm analysis + # add anything else other than pus_tc verification counter + # and ssc that is needed for pus_tm analysis return assertion_dict def analyse_tc_info(self, tc_info_queue): diff --git a/tmtc_core b/tmtc_core index c74f0dcf3edc005210de65fa744e2ec12fabe38c..5e48f63eceb7a44ad9f9cf82fff238f862a707f1 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit c74f0dcf3edc005210de65fa744e2ec12fabe38c +Subproject commit 5e48f63eceb7a44ad9f9cf82fff238f862a707f1 diff --git a/utility/tmtcc_args_parser.py b/utility/tmtcc_args_parser.py index a840c381e99e3abf75cc960561e4f241702a1556..059da5defa4e2e7f6812df3ab928c98cb1e4e811 100644 --- a/utility/tmtcc_args_parser.py +++ b/utility/tmtcc_args_parser.py @@ -98,8 +98,8 @@ def handle_unspecified_args(args) -> None: print("Possible Modes: ") print("1: Listener Mode") print("2: Single Command Mode with manual command") - print("3: Service Mode, Commands specified in tc folder") - print("4: Software Mode, runs all command specified in obsw_pus_tc_packer.py") + print("3: Service Mode, Commands specified in pus_tc folder") + print("4: Software Mode, runs all command specified in tmtcc_pus_tc_packer.py") print("5: Unit Test, runs unit test specified in obsw_module_test.py") args.mode = input("Please enter Mode: ") if args.mode == 1 and args.service is None: diff --git a/utility/tmtcc_binary_uploader.py b/utility/tmtcc_binary_uploader.py index 73bbb6fa05f59c542f1bf03489897fda6f6e2019..c1c8417ce03cf87e9a297fddcff0ba792cd69452 100644 --- a/utility/tmtcc_binary_uploader.py +++ b/utility/tmtcc_binary_uploader.py @@ -13,9 +13,9 @@ from tkinter import filedialog from collections import deque from glob import glob -from tmtc_core.tm.tmtcc_tm_service_1 import Service1TM +from tmtc_core.pus_tm.tmtcc_tm_service_1 import Service1TM from tmtc_core.comIF.obsw_com_interface import CommunicationInterface -from tmtc_core.tc.tmtcc_pus_tc_base import TcQueueT, TcDictionaryKeys +from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT, TcDictionaryKeys from utility.tmtcc_file_transfer_helper import FileTransferHelper import config.tmtcc_config as g from tmtc_core.utility.obsw_tmtc_printer import TmTcPrinter, DisplayMode diff --git a/utility/tmtcc_file_transfer_helper.py b/utility/tmtcc_file_transfer_helper.py index a3b62558ad269558bafc63dbf2805ea677593664..4a47de3dcfb013c5dcc25d5e38eff292eee4bbbc 100644 --- a/utility/tmtcc_file_transfer_helper.py +++ b/utility/tmtcc_file_transfer_helper.py @@ -2,8 +2,8 @@ from enum import Enum import math from config.tmtcc_config import SD_CARD_HANDLER_ID -from tmtc_core.tc.tmtcc_pus_tc_base import TcQueueT, PusTelecommand -from tc.obsw_tc_service23_sdcard import \ +from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT, PusTelecommand +from pus_tc.tmtcc_tc_service23_sdcard import \ calculate_allowed_file_data_size, generate_rm_file_srv23_2_packet, \ generate_create_file_srv23_1_packet, generate_finish_append_to_file_srv23_131_packet, \ generate_lock_file_srv23_5_6_packet