diff --git a/config/obsw_config.py b/config/obsw_config.py index 9118571c3eb2418bb410e4877d0be53025fd2ec0..49f10554e608d768e8db4511d68ee34d9b1017df 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -29,10 +29,11 @@ class ModeList(enum.Enum): class ComIF(enum.Enum): - Ethernet = 0 + Dummy = 0 Serial = 1 QEMU = 2 - Dummy = 3 + Ethernet = 3 + """ @@ -142,11 +143,11 @@ def set_globals(args): G_MODE_ID = ModeList.UnitTest else: G_MODE_ID = ModeList[1] - if args.com_if == 0: + if args.com_if == ComIF.Ethernet.value: G_COM_IF = ComIF.Ethernet - elif args.com_if == 1: + elif args.com_if == ComIF.Serial.value: G_COM_IF = ComIF.Serial - elif args.com_if == 2: + elif args.com_if == ComIF.QEMU.value: G_COM_IF = ComIF.QEMU else: G_COM_IF = ComIF.Dummy diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index 3827b487b6ebe4263b79003738f738418b59f7d2..a046b9d8ac85d79f14e1649b4fb0c5403a209457 100644 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -1,8 +1,11 @@ #!/usr/bin/python3.8 # -*- coding: utf-8 -*- """ -This client was developed by KSat for the SOURCE project to test the on-board software. -It can be used to to send and receive TMTC packets and TMTC sequences. +@brief This client was developed by KSat for the SOURCE project to test the on-board software. +@details +This client features multiple sender/receiver modes and has been designed +to be extensible and easy to use. This clien is based on the PUS standard for the format +of telecommands and telemetry. @manual Manual installation of crcmod and pyserial for serial communication might be needed @@ -17,14 +20,12 @@ GUI is work-in-progress It might be necessary to set board or PC IP address if using ethernet communication. Default values should work normally though. Use higher timeout value (-t Parameter) for STM32 -Example command to test G_SERVICE 17, -assuming no set client IP (set manually to PC IP Address if necessary) -and default board IP 169.254.1.38: - obsw_tmtc_client.py -m 3 -s 17 -Example to run Unit Test: - obsw_tmtc_client.py -m 5 -Example to test G_SERVICE 17 with HK output and serial communication: - obsw_tmtc_client.py -m 3 -s 17 --hk -c 1 +Example command to test PUS Service 17 with serial communication + obsw_tmtc_client.py -m 3 -s 17 -c 1 +Example to run Unit Test with QEMU: + obsw_tmtc_client.py -m 5 -c 2 +Example to test service 3 with HK output and serial communication: + obsw_tmtc_client.py -m 3 -s 3 --hk -c 1 Get command line help: obsw_tmtc_client.py -h @@ -40,12 +41,18 @@ There are four different Modes: 5. Unit Test Mode: Performs a unit test which returns a simple OK or NOT OK. This mode has the capability to send TCs in bursts, where applicable -If there are problems receiving packets with Ethernet Communication, -use the tool Wireshark to track ethernet communication -for UDP echo packets (requests and response). -If the packets appear, there might be a problematic firewall setting. -Please ensure that python.exe UDP packets are not blocked in advanced firewall settings -and create a rule to allow packets from port 2008. +There are following communication interfaces, specified by supplying -c <Interface ID>: + 0: Dummy Interface: Not fully developed yet. + 1: Serial Interface: Serial communication. Specify COM port with --COM <Com Port Name> + or type it in manually. Serial settings are hardcoded for now in obsw_com_config.py . + TODO: Serial settings should be able to be set from the command line + 2: QEMU Interface: Start a QEMU session and then command the session with the QEMU interface. + 3. Ethernet: Not used anymore. Can be used to send packets to sockets by specifying the + port and IP address. + +If there are problems receiving packets with Ethernet Communication, check the firewall +settings and ensure that python.exe UDP packets are not blocked in advanced firewall settings +Create a rule to allow packets from port 2008 if necessary. """ import atexit import time @@ -57,7 +64,7 @@ from collections import deque 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, service_test_select +from tc.obsw_pus_tc_packer import PusTelecommand, create_total_tc_queue, pack_service_queue from sendreceive.obsw_single_command_sender_receiver import SingleCommandSenderReceiver from sendreceive.obsw_sequential_sender_receiver import SequentialCommandSenderReceiver @@ -79,7 +86,7 @@ LOGGER = get_logger() def main(): """ - Main method, reads input arguments, sets global variables and start TMTC handler + Main method, reads input arguments, sets global variables and start TMTC handler. """ set_tmtc_logger() LOGGER.info("Starting TMTC Client") @@ -180,11 +187,11 @@ class TmTcHandler: elif self.mode == g.ModeList.ServiceTestMode: service_queue = deque() + pack_service_queue(g.G_SERVICE, service_queue) LOGGER.info("Performing service command operation") sender_and_receiver = SequentialCommandSenderReceiver( com_interface=communication_interface, tmtc_printer=tmtc_printer, - tm_listener=tm_listener, - tc_queue=service_test_select(g.G_SERVICE, service_queue)) + tm_listener=tm_listener, tc_queue=service_queue) sender_and_receiver.send_queue_tc_and_receive_tm_sequentially() elif self.mode == g.ModeList.SoftwareTestMode: diff --git a/tc/obsw_pus_tc_base.py b/tc/obsw_pus_tc_base.py index b8966b42fd158313720fef01ea4828b2d76f779b..c5519f0978588b0c201b1fd98aeea4a23d6b790f 100644 --- a/tc/obsw_pus_tc_base.py +++ b/tc/obsw_pus_tc_base.py @@ -1,6 +1,8 @@ """ +@file obsw_pus_tc_base.py @brief This module contains the PUS telemetry class representation to deserialize raw PUS telemetry packets. +@author R. Mueller """ from enum import Enum from typing import Dict, Union, Tuple, Deque diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index 9650005c2efc31e0e0aacdb42accb7c63616a62b..af185553ca87016c31d7cffbc6bad8809a612d85 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -1,15 +1,11 @@ # -*- coding: utf-8 -*- """ -Program: obsw_module_test.py -Date: 01.11.2019 -Description: Packs the TC queue for specific G_SERVICE or device testing - -Manual: -Contains a G_SERVICE select factory which returns specific G_SERVICE or device tests. -Also contains an all G_SERVICE and all device tc queue packer. -Run script with -s <Service or Device> -m 3 with optional -p parameter for file output inside the log folder - -@author: R. Mueller +@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 @@ -17,45 +13,47 @@ from tc.obsw_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_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_tc_gps import pack_gps_test_into + from utility.obsw_logger import get_logger import config.obsw_config as g -from datetime import datetime from collections import deque from typing import Union LOGGER = get_logger() -def service_test_select(service: Union[int, str], service_queue: TcQueueT) -> TcQueueT: +def pack_service_queue(service: Union[int, str], service_queue: TcQueueT): if service == 2: return pack_service2_test_into(service_queue) - elif service == 3: + if service == 3: return pack_service3_test_into(service_queue) - elif service == 5: + if service == 5: return pack_service5_test_into(service_queue) - elif service == 8: + if service == 8: return pack_service8_test_into(service_queue) - elif service == 9: + if service == 9: return pack_service9_test_into(service_queue) - elif service == 17: + if service == 17: return pack_service17_test_into(service_queue) - elif service == 200: + if service == 200: return pack_service200_test_into(service_queue) - elif service == "Dummy": + if service == "Dummy": return pack_dummy_device_test_into(service_queue) - elif service == "GPS0": + if service == "GPS0": # Object ID: GPS Device object_id = g.GPS0_ObjectId return pack_gps_test_into(object_id, service_queue) - elif service == "GPS1": + if service == "GPS1": # Object ID: GPS Device object_id = g.GPS1_ObjectId return pack_gps_test_into(object_id, service_queue) - elif service == "Error": + if service == "Error": return pack_error_testing_into(service_queue) - else: - print("Invalid Service !") - exit() + 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: @@ -74,71 +72,6 @@ def create_total_tc_queue() -> TcQueueT: tc_queue = pack_gps_test_into(object_id, tc_queue) return tc_queue -def pack_service5_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Service 5")) - # 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_service9_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Service 9")) - time_test_ascii_code_a = '2019-08-30T20:50:33.892429Z' + '\0' - time_test_ascii_code_b = '2019-270T05:50:33.002000Z' + '\0' - time_test_current_time = datetime.now().isoformat() + "Z" + '\0' - time_test1 = time_test_ascii_code_a.encode('ascii') - time_test2 = time_test_ascii_code_b.encode('ascii') - time_test3 = time_test_current_time.encode('ascii') - LOGGER.info("Time Code 1 :%s", time_test1) - LOGGER.info("Time Code 2 :%s", time_test2) - LOGGER.info("Time Code 3 :%s", time_test3) - # time setting - tc_queue.appendleft(("print", "Testing Service 9: Testing timecode A")) - command = PusTelecommand(service=9, subservice=128, ssc=900, app_data=bytearray(time_test1)) - tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "Testing Service 9: Testing timecode B")) - command = PusTelecommand(service=9, subservice=128, ssc=910, app_data=bytearray(time_test2)) - tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "Testing Service 9: Testing timecode Current Time")) - command = PusTelecommand(service=9, subservice=128, ssc=920, app_data=bytearray(time_test3)) - tc_queue.appendleft(command.pack_command_tuple()) - # TODO: Add other time formats here - tc_queue.appendleft(("export", "log/tmtc_log_service9.txt")) - return tc_queue - - -def pack_service17_test_into(tc_queue: TcQueueT) -> TcQueueT: - 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()) - # enable event - tc_queue.appendleft(("print", "Testing Service 17: Enable Event")) - command = PusTelecommand(service=5, subservice=5, ssc=52) - tc_queue.appendleft(command.pack_command_tuple()) - # test event - tc_queue.appendleft(("print", "Testing Service 17: Trigger event")) - command = PusTelecommand(service=17, subservice=128, ssc=1701) - tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("export", "log/tmtc_log_service17.txt")) - return tc_queue - def pack_dummy_device_test_into(tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(("print", "Testing Dummy Device")) @@ -158,53 +91,6 @@ def pack_dummy_device_test_into(tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(("export", "log/tmtc_log_service_dummy.txt")) return tc_queue - -def pack_gps_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - if object_id == g.GPS0_ObjectId: - gps_string = "GPS0" - elif object_id == g.GPS1_ObjectId: - gps_string = "GPS1" - else: - gps_string = "unknown" - tc_queue.appendleft(("print", "Testing " + gps_string + " Device")) - # Set Mode Off - tc_queue.appendleft(("print", "Testing " + gps_string + ": Set Off")) - mode_data = pack_mode_data(object_id, 0, 0) - command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) - # Set Mode On - tc_queue.appendleft(("print", "Testing " + gps_string + ": Set On")) - mode_data = pack_mode_data(object_id, 1, 0) - command = PusTelecommand(service=200, subservice=1, ssc=12, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) - # Enable HK report - sid_gps = 0 - if object_id == g.GPS0_ObjectId: - sid_gps = g.GPS0_SID - tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) - command = PusTelecommand(service=3, subservice=5, ssc=13, app_data=sid_gps) - tc_queue.appendleft(command.pack_command_tuple()) - elif object_id == g.GPS1_ObjectId: - sid_gps = g.GPS1_SID - tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) - command = PusTelecommand(service=3, subservice=5, ssc=14, app_data=sid_gps) - tc_queue.appendleft(command.pack_command_tuple()) - # pack wait interval until mode is on and a few gps replies have been received - tc_queue.appendleft(("wait", 5)) - # Disable HK reporting - tc_queue.appendleft(("print", "Testing Service 3: Disable " + gps_string + " definition")) - command = PusTelecommand(service=3, subservice=6, ssc=15, app_data=sid_gps) - tc_queue.appendleft(command.pack_command_tuple()) - # Set Mode Off - tc_queue.appendleft(("print", "Testing " + gps_string + ": Set Off")) - mode_data = pack_mode_data(object_id, 0, 0) - command = PusTelecommand(service=200, subservice=1, ssc=13, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "\r")) - tc_queue.appendleft(("export", "log/tmtc_log_service_" + gps_string + ".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) diff --git a/tc/obsw_tc_gps.py b/tc/obsw_tc_gps.py new file mode 100644 index 0000000000000000000000000000000000000000..e7edd53747d5fda55524a80f99c6304ce3021e34 --- /dev/null +++ b/tc/obsw_tc_gps.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +""" +@file obsw_tc_gps.py +@brief GPS Device: GPS device testing +@author R. Mueller +@date 02.05.2020 +""" + +from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand +from tc.obsw_tc_service2 import pack_mode_data + +import config.obsw_config as g + +def pack_gps_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: + if object_id == g.GPS0_ObjectId: + gps_string = "GPS0" + elif object_id == g.GPS1_ObjectId: + gps_string = "GPS1" + else: + gps_string = "unknown" + tc_queue.appendleft(("print", "Testing " + gps_string + " Device")) + # Set Mode Off + tc_queue.appendleft(("print", "Testing " + gps_string + ": Set Off")) + mode_data = pack_mode_data(object_id, 0, 0) + command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + # Set Mode On + tc_queue.appendleft(("print", "Testing " + gps_string + ": Set On")) + mode_data = pack_mode_data(object_id, 1, 0) + command = PusTelecommand(service=200, subservice=1, ssc=12, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + # Enable HK report + sid_gps = 0 + if object_id == g.GPS0_ObjectId: + sid_gps = g.GPS0_SID + tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) + command = PusTelecommand(service=3, subservice=5, ssc=13, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + elif object_id == g.GPS1_ObjectId: + sid_gps = g.GPS1_SID + tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) + command = PusTelecommand(service=3, subservice=5, ssc=14, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + # pack wait interval until mode is on and a few gps replies have been received + tc_queue.appendleft(("wait", 5)) + # Disable HK reporting + tc_queue.appendleft(("print", "Testing Service 3: Disable " + gps_string + " definition")) + command = PusTelecommand(service=3, subservice=6, ssc=15, app_data=sid_gps) + tc_queue.appendleft(command.pack_command_tuple()) + # Set Mode Off + tc_queue.appendleft(("print", "Testing " + gps_string + ": Set Off")) + mode_data = pack_mode_data(object_id, 0, 0) + command = PusTelecommand(service=200, subservice=1, ssc=13, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(("export", "log/tmtc_log_service_" + gps_string + ".txt")) + return tc_queue diff --git a/tc/obsw_tc_service2.py b/tc/obsw_tc_service2.py index 5e04926afdcea39008c71158e373ef10dc75c326..1e44d9269fb2861b9134d9b54c7408c050ce4a2a 100644 --- a/tc/obsw_tc_service2.py +++ b/tc/obsw_tc_service2.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- """ -Program: obsw_module_test.py -Date: 01.11.2019 -Description: PUS Custom Service 8: Device Access, Native low-level commanding - -@author: R. Mueller +@file obsw_tc_service2.py +@brief PUS Service 2: Device Access, Native low-level commanding +@author R. Mueller +@date 01.11.2019 """ import struct diff --git a/tc/obsw_tc_service200.py b/tc/obsw_tc_service200.py index cd91a2d525525923c0206b39c759b111014b84b1..6ed06e889b1b8fb9e596470dc0e7577895ee7364 100644 --- a/tc/obsw_tc_service200.py +++ b/tc/obsw_tc_service200.py @@ -1,15 +1,9 @@ # -*- coding: utf-8 -*- """ -Program: obsw_tc_service200.py -Date: 01.11.2019 -Description: PUS Custom Service 200: Mode Commanding - -Manual: -Contains a G_SERVICE select factory which returns specific G_SERVICE or device tests. -Also contains an all G_SERVICE and all device tc queue packer. -Run script with -s <Service or Device> -m 3 with optional -p parameter for file output inside the log folder - -@author: R. Mueller +@file obsw_tc_service200.py +@brief PUS Service 200: PUS custom service 200: Mode commanding +@author R. Mueller +@date 02.05.2020 """ from tc.obsw_pus_tc_base import PusTelecommand from tc.obsw_pus_tc_packer import TcQueueT diff --git a/tc/obsw_tc_service3.py b/tc/obsw_tc_service3.py index 2dbb3f07b994e393c81fa289371121f6e45e3487..89d90612a2badc148f0e99e44bf1477d7585fe17 100644 --- a/tc/obsw_tc_service3.py +++ b/tc/obsw_tc_service3.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- """ -Program: obsw_module_test.py -Date: 01.11.2019 -Description: PUS Custom Service 8: Device Access, Native low-level commanding - -@author: R. Mueller +@file obsw_tc_service3.py +@brief PUS Service 3: Housekeeping Service. +@author R. Mueller +@date 02.05.2020 """ import struct from typing import Deque diff --git a/tc/obsw_tc_service5_17.py b/tc/obsw_tc_service5_17.py new file mode 100644 index 0000000000000000000000000000000000000000..bd8f9a896c7fbc4a437f9a54c63e936b7438cd13 --- /dev/null +++ b/tc/obsw_tc_service5_17.py @@ -0,0 +1,49 @@ +# -*- 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 +""" + +from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand + +def pack_service5_test_into(tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft(("print", "Testing Service 5")) + # 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) -> TcQueueT: + 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()) + # enable event + tc_queue.appendleft(("print", "Testing Service 17: Enable Event")) + command = PusTelecommand(service=5, subservice=5, ssc=52) + tc_queue.appendleft(command.pack_command_tuple()) + # test event + tc_queue.appendleft(("print", "Testing Service 17: Trigger event")) + command = PusTelecommand(service=17, subservice=128, ssc=1701) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(("export", "log/tmtc_log_service17.txt")) + return tc_queue diff --git a/tc/obsw_tc_service8.py b/tc/obsw_tc_service8.py index 8a0bb2f16479b6c3a881d0652f3ee227b47899f0..bc0b8592a32afae7dcac5b825f596ebb74fffe0c 100644 --- a/tc/obsw_tc_service8.py +++ b/tc/obsw_tc_service8.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- """ -Program: obsw_module_test.py -Date: 01.11.2019 -Description: PUS Custom Service 8: Function Management, High-Level Commanding - -@author: R. Mueller +@file obsw_tc_service8.py +@brief PUS Service 8: High-level functional commanding. +@author R. Mueller +@date 01.11.2019 """ from typing import Deque diff --git a/tc/obsw_tc_service9.py b/tc/obsw_tc_service9.py new file mode 100644 index 0000000000000000000000000000000000000000..287d5a500c8dc90860a1d8b75f163a92dfae65b7 --- /dev/null +++ b/tc/obsw_tc_service9.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +""" +@file obsw_tc_service9.py +@brief PUS Service 9: Time management. +@author R. Mueller +@date 01.11.2019 +""" + +from datetime import datetime +from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand +from utility.obsw_logger import get_logger + +LOGGER = get_logger() + + +def pack_service9_test_into(tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft(("print", "Testing Service 9")) + time_test_ascii_code_a = '2019-08-30T20:50:33.892429Z' + '\0' + time_test_ascii_code_b = '2019-270T05:50:33.002000Z' + '\0' + time_test_current_time = datetime.now().isoformat() + "Z" + '\0' + time_test1 = time_test_ascii_code_a.encode('ascii') + time_test2 = time_test_ascii_code_b.encode('ascii') + time_test3 = time_test_current_time.encode('ascii') + LOGGER.info("Time Code 1 :%s", time_test1) + LOGGER.info("Time Code 2 :%s", time_test2) + LOGGER.info("Time Code 3 :%s", time_test3) + # time setting + tc_queue.appendleft(("print", "Testing Service 9: Testing timecode A")) + command = PusTelecommand(service=9, subservice=128, ssc=900, app_data=bytearray(time_test1)) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(("print", "Testing Service 9: Testing timecode B")) + command = PusTelecommand(service=9, subservice=128, ssc=910, app_data=bytearray(time_test2)) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft(("print", "Testing Service 9: Testing timecode Current Time")) + command = PusTelecommand(service=9, subservice=128, ssc=920, app_data=bytearray(time_test3)) + tc_queue.appendleft(command.pack_command_tuple()) + # TODO: Add other time formats here + tc_queue.appendleft(("export", "log/tmtc_log_service9.txt")) + return tc_queue \ No newline at end of file