From de479a6e56c9776ec8330edfb0970a5baf203f51 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Thu, 30 Apr 2020 21:38:18 +0200 Subject: [PATCH] service 3 testing extended printout changed: lprint for optimized logprint/debug print --- config/obsw_config.py | 4 +- sendreceive/obsw_command_sender_receiver.py | 4 + tc/obsw_tc_service3.py | 191 ++++++++++++-------- utility/obsw_tmtc_printer.py | 4 - 4 files changed, 122 insertions(+), 81 deletions(-) diff --git a/config/obsw_config.py b/config/obsw_config.py index 735faf9..9118571 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -56,8 +56,8 @@ DUMMY_COMMAND_3 = bytearray([0xBA, 0xDE, 0xAF, 0xFE]) # SIDs GPS0_SID = bytearray([0x00, 0x00, 0x1f, 0x00]) GPS1_SID = bytearray([0x00, 0x00, 0x2f, 0x00]) -CUSTOM_SID_1 = bytearray([0x00, 0x00, 0x43, 0x00]) -CUSTOM_SID_2 = bytearray([0x00, 0x00, 0x44, 0x00]) +TEST_SID = bytearray([0x00, 0x00, 0x43, 0x00]) +CUSTOM_SID = bytearray([0x00, 0x00, 0x44, 0x00]) # Pool IDs TEST_ID_1 = bytearray([0x01, 0x01, 0x01, 0x02]) TEST_ID_2 = bytearray([0x02, 0x02, 0x02, 0x04]) diff --git a/sendreceive/obsw_command_sender_receiver.py b/sendreceive/obsw_command_sender_receiver.py index c72f573..36b96aa 100644 --- a/sendreceive/obsw_command_sender_receiver.py +++ b/sendreceive/obsw_command_sender_receiver.py @@ -119,6 +119,10 @@ class CommandSenderReceiver: time.sleep(wait_time) elif queue_entry_first == "print": print_string = queue_entry_second + self._tmtc_printer.print_string(print_string, False) + elif queue_entry_first == "lprint": + print_string = queue_entry_second + print() self._tmtc_printer.print_string(print_string, True) elif queue_entry_first == "export": export_name = queue_entry_second diff --git a/tc/obsw_tc_service3.py b/tc/obsw_tc_service3.py index 5b46404..d5913c8 100644 --- a/tc/obsw_tc_service3.py +++ b/tc/obsw_tc_service3.py @@ -11,115 +11,156 @@ from typing import Deque from tc.obsw_pus_tc_base import PusTelecommand import config.obsw_config as g +# adding custom defintion to hk using test pool variables +sid_test = g.TEST_SID +sid_custom = g.CUSTOM_SID +sid_gps = g.GPS0_SID +collection_interval_hk = struct.pack('>f', 3) +collection_interval_diag = struct.pack('>f',0.8) +number_of_parameters = struct.pack('>B', 5) +p1 = g.TEST_ID_1 +p2 = g.TEST_ID_2 +p3 = g.TEST_ID_3 +p4 = g.TEST_ID_4 +p5 = g.TEST_ID_5 +hk_definition = sid_test + collection_interval_hk + number_of_parameters + p1 + p2 + p3 + p4 + p5 +diag_definition = (sid_custom + collection_interval_diag + number_of_parameters + + p1 + p2 + p3 + p4 + p5) def pack_service3_test_into(tc_queue: Deque) -> Deque: tc_queue.appendleft(("print", "Testing Service 3")) - # adding custom defintion to hk using test pool variables - sid1 = g.CUSTOM_SID_1 - sid2 = g.CUSTOM_SID_2 - sid_gps = g.GPS0_SID - collection_interval = struct.pack('>f', 3) - number_of_parameters = struct.pack('>B', 5) - p1 = g.TEST_ID_1 - p2 = g.TEST_ID_2 - p3 = g.TEST_ID_3 - p4 = g.TEST_ID_4 - p5 = g.TEST_ID_5 - hk_definition1 = sid1 + collection_interval + number_of_parameters + p1 + p2 + p3 + p4 + p5 - collection_interval = struct.pack('>f', 6) - hk_definition2 = sid2 + collection_interval + number_of_parameters + p1 + p2 + p3 + p4 + p5 + # Predefined packet testing + # pack_predefined_tests(tc_queue) + pack_custom_tests(tc_queue) + + tc_queue.appendleft(("export", "log/tmtc_log_service3.txt")) + return tc_queue + +def pack_predefined_tests(tc_queue: Deque): + # enable gps0 + tc_queue.appendleft(("print", "Testing Service 3: Enable GPS definition")) + command = PusTelecommand(service=3, subservice=5, ssc=3000, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + + # enable test + tc_queue.appendleft(("print", "Testing Service 3: Enable test definition")) + command = PusTelecommand(service=3, subservice=5, ssc=3010, app_data=sid_test) + tc_queue.appendleft(command.pack_command_tuple()) + + # wait a bit to receive at least 2 packets.. + tc_queue.appendleft(("wait", 2)) + + # disable gps0 + tc_queue.appendleft(("print", "Testing Service 3: Disable GPS definition")) + command = PusTelecommand(service=3, subservice=6, ssc=3020, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + + # disable test + tc_queue.appendleft(("print", "Testing Service 3: Disable test definition")) + command = PusTelecommand(service=3, subservice=6, ssc=3030, app_data=sid_test) + tc_queue.appendleft(command.pack_command_tuple()) + + # report gps definition + tc_queue.appendleft(("print", "Testing Service 3: Reporting GPS definition")) + command = PusTelecommand(service=3, subservice=9, ssc=3040, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + + # report test definition + tc_queue.appendleft(("print", "Testing Service 3: Reporting test definition")) + command = PusTelecommand(service=3, subservice=9, ssc=3050, app_data=sid_test) + tc_queue.appendleft(command.pack_command_tuple()) + + # generate one gps 0 definition + tc_queue.appendleft(("print", "Testing Service 3: Generate one gps 0 defintion")) + command = PusTelecommand(service=3, subservice=27, ssc=3060, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + + # generate test definition + tc_queue.appendleft(("print", "Testing Service 3: Generate test defintion")) + command = PusTelecommand(service=3, subservice=27, ssc=3070, app_data=sid_test) + tc_queue.appendleft(command.pack_command_tuple()) + +def pack_custom_tests(tc_queue: Deque): # deleting pre-defined test entry - tc_queue.appendleft(("print", "Testing Service 3: Deleting pre-defined HK definition")) - command = PusTelecommand(service=3, subservice=3, ssc=3000, app_data=sid1) + tc_queue.appendleft(("lprint", "Testing Service 3: Deleting pre-defined HK definition")) + command = PusTelecommand(service=3, subservice=3, ssc=3100, app_data=sid_test) tc_queue.appendleft(command.pack_command_tuple()) # adding pre-defined definition to hk using test pool variables - tc_queue.appendleft(("print", "Testing Service 3: Adding pre-defined HK definition")) - command = PusTelecommand(service=3, subservice=1, ssc=3010, app_data=hk_definition1) + tc_queue.appendleft(("lprint", "Testing Service 3: Adding pre-defined HK definition")) + command = PusTelecommand(service=3, subservice=1, ssc=3110, app_data=hk_definition) tc_queue.appendleft(command.pack_command_tuple()) # adding custom definition to diagnostics using test pool variables - tc_queue.appendleft(("print", "Testing Service 3: Adding custom diganostics definition")) - command = PusTelecommand(service=3, subservice=2, ssc=3020, app_data=hk_definition2) + tc_queue.appendleft(("lprint", "Testing Service 3: Adding custom diganostics definition")) + command = PusTelecommand(service=3, subservice=2, ssc=3120, app_data=diag_definition) tc_queue.appendleft(command.pack_command_tuple()) # enable custom hk definition - tc_queue.appendleft(("print", "Testing Service 3: Enable custom definition")) - command = PusTelecommand(service=3, subservice=5, ssc=3030, app_data=sid1) + tc_queue.appendleft(("lprint", "Testing Service 3: Enable custom definition")) + command = PusTelecommand(service=3, subservice=5, ssc=3130, app_data=hk_definition) tc_queue.appendleft(command.pack_command_tuple()) + # enable custom diag definition - tc_queue.appendleft(("print", "Testing Service 3: Enable custom diagnostics definition")) - command = PusTelecommand(service=3, subservice=7, ssc=3040, app_data=sid2) - tc_queue.appendleft(command.pack_command_tuple()) - # enable gps0 - tc_queue.appendleft(("print", "Testing Service 3: Enable GPS definition")) - command = PusTelecommand(service=3, subservice=5, ssc=3050, app_data=sid_gps) + tc_queue.appendleft(("lprint", "Testing Service 3: Enable custom diagnostics definition")) + command = PusTelecommand(service=3, subservice=7, ssc=3140, app_data=diag_definition) tc_queue.appendleft(command.pack_command_tuple()) - # maybe wait a bit to receive at least 2 packets.. - tc_queue.appendleft(("wait", 3)) + # Disable custom diag definition + tc_queue.appendleft(("lprint", "Testing Service 3: Disable custom diagnostics definition")) + command = PusTelecommand(service=3, subservice=8, ssc=3160, app_data=sid_custom) + tc_queue.appendleft(command.pack_command_tuple()) # Disable custom hk definition - tc_queue.appendleft(("print", "Testing Service 3: Disable custom definition")) - command = PusTelecommand(service=3, subservice=6, ssc=3060, app_data=sid1) - tc_queue.appendleft(command.pack_command_tuple()) - # Disable custom diag definition - tc_queue.appendleft(("print", "Testing Service 3: Disable custom diagnostics definition")) - command = PusTelecommand(service=3, subservice=8, ssc=3070, app_data=sid2) + tc_queue.appendleft(("lprint", "Testing Service 3: Disable custom definition")) + command = PusTelecommand(service=3, subservice=6, ssc=3150, app_data=sid_test) tc_queue.appendleft(command.pack_command_tuple()) - # disable gps0 - tc_queue.appendleft(("print", "Testing Service 3: Disable GPS definition")) - command = PusTelecommand(service=3, subservice=6, ssc=3080, app_data=sid_gps) + + # report custom test definition + tc_queue.appendleft(("lprint", "Testing Service 3: Reporting hk definition")) + command = PusTelecommand(service=3, subservice=9, ssc=3170, app_data=sid_test) tc_queue.appendleft(command.pack_command_tuple()) + # report custom Diag definition - tc_queue.appendleft(("print", "Testing Service 3: Reporting diag definition")) - command = PusTelecommand(service=3, subservice=11, ssc=3100, app_data=sid2) - tc_queue.appendleft(command.pack_command_tuple()) - # report gps definition - tc_queue.appendleft(("print", "Testing Service 3: Reporting GPS definition")) - command = PusTelecommand(service=3, subservice=9, ssc=3110, app_data=sid_gps) + tc_queue.appendleft(("lprint", "Testing Service 3: Reporting diag definition")) + command = PusTelecommand(service=3, subservice=11, ssc=3180, app_data=sid_custom) tc_queue.appendleft(command.pack_command_tuple()) + # generate one custom hk definition - tc_queue.appendleft(("print", "Testing Service 3: Generate one custom hk definition")) - command = PusTelecommand(service=3, subservice=27, ssc=3120, app_data=sid1) + tc_queue.appendleft(("lprint", "Testing Service 3: Generate one custom hk definition")) + command = PusTelecommand(service=3, subservice=27, ssc=3190, app_data=sid_test) tc_queue.appendleft(command.pack_command_tuple()) + # generate one custom diag definition - tc_queue.appendleft(("print", "Testing Service 3: Generate one custom diagnostics definition")) - command = PusTelecommand(service=3, subservice=28, ssc=3120, app_data=sid2) - tc_queue.appendleft(command.pack_command_tuple()) - # generate one gps 0 definition - tc_queue.appendleft(("print", "Testing Service 3: Generate one gps 0 defintion")) - command = PusTelecommand(service=3, subservice=27, ssc=3120, app_data=sid_gps) + tc_queue.appendleft(("lprint", "Testing Service 3: Generate one custom diagnostics definition")) + command = PusTelecommand(service=3, subservice=28, ssc=3200, app_data=sid_custom) tc_queue.appendleft(command.pack_command_tuple()) + # modify custom hk definition interval - new_interval = struct.pack('>f', 10.0) - new_interval_command = sid1 + new_interval - tc_queue.appendleft(("print", "Testing Service 3: Changing pre-defined HK definition interval")) - command = PusTelecommand(service=3, subservice=31, ssc=3090, app_data=new_interval_command) - tc_queue.appendleft(command.pack_command_tuple()) + # new_interval = struct.pack('>f', 10.0) + # new_interval_command = sid1 + new_interval + # tc_queue.appendleft(("print", "Testing Service 3: Changing pre-defined HK definition interval")) + # command = PusTelecommand(service=3, subservice=31, ssc=3090, app_data=new_interval_command) + # tc_queue.appendleft(command.pack_command_tuple()) # report custom HK definition - tc_queue.appendleft(("print", "Testing Service 3: Reporting pre-defined HK definition with changed interval")) - command = PusTelecommand(service=3, subservice=9, ssc=3090, app_data=sid1) - tc_queue.appendleft(command.pack_command_tuple()) + # tc_queue.appendleft(("print", "Testing Service 3: Reporting pre-defined HK definition with changed interval")) + # command = PusTelecommand(service=3, subservice=9, ssc=3090, app_data=sid1) + # tc_queue.appendleft(command.pack_command_tuple()) # modify custom diag definition interval - new_interval_command = sid2 + new_interval - tc_queue.appendleft(("print", "Testing Service 3: Changing custom diag HK definition interval")) - command = PusTelecommand(service=3, subservice=32, ssc=3090, app_data=new_interval_command) - tc_queue.appendleft(command.pack_command_tuple()) + # new_interval_command = sid2 + new_interval + # tc_queue.appendleft(("print", "Testing Service 3: Changing custom diag HK definition interval")) + # command = PusTelecommand(service=3, subservice=32, ssc=3090, app_data=new_interval_command) + # tc_queue.appendleft(command.pack_command_tuple()) # report custom diag definition - tc_queue.appendleft(("print", "Testing Service 3: Reporting diag definition")) - command = PusTelecommand(service=3, subservice=11, ssc=3100, app_data=sid2) - tc_queue.appendleft(command.pack_command_tuple()) + # tc_queue.appendleft(("print", "Testing Service 3: Reporting diag definition")) + # command = PusTelecommand(service=3, subservice=11, ssc=3100, app_data=sid2) + # tc_queue.appendleft(command.pack_command_tuple()) # append parameter to custom hk definiton # append parameter to custom diag definition # delete custom diag definition - tc_queue.appendleft(("print", "Testing Service 3: Deleting custom diagnostics definition")) - command = PusTelecommand(service=3, subservice=4, ssc=3120, app_data=sid2) - tc_queue.appendleft(command.pack_command_tuple()) + # tc_queue.appendleft(("print", "Testing Service 3: Deleting custom diagnostics definition")) + # command = PusTelecommand(service=3, subservice=4, ssc=3120, app_data=sid2) + # tc_queue.appendleft(command.pack_command_tuple()) - # do some basic testing on predefined structs too - # e.g. add one variable, change interval, report them.... - tc_queue.appendleft(("export", "log/tmtc_log_service3.txt")) - return tc_queue diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py index a0dc8e7..cf40f43 100644 --- a/utility/obsw_tmtc_printer.py +++ b/utility/obsw_tmtc_printer.py @@ -61,7 +61,6 @@ class TmTcPrinter: :param packet: :return: """ - print() # LOGGER.debug(packet.return_full_packet_string()) if self.display_mode == DisplayMode.SHORT: self.__handle_short_print(packet) @@ -277,8 +276,6 @@ class TmTcPrinter: LOGGER.info("Log file written to %s", log_name) file.close() - - @staticmethod def bit_extractor(byte: int, position: int): """ @@ -298,7 +295,6 @@ class TmTcPrinter: :return: """ if self.print_tc: - print() if len(tc_packet) == 0: LOGGER.error("TMTC Printer: Empty packet was sent, configuration error") return -- GitLab