From a9d750940f31b46a5ee20471fc7ad0659261cc06 Mon Sep 17 00:00:00 2001 From: "Jan.Gerhards" <jan@gerhards.net> Date: Sun, 5 Jul 2020 11:14:14 +0200 Subject: [PATCH] continue implementing service 20 tests --- tc/obsw_tc_service20.py | 61 ++++++++++++++++++++++++--------------- tm/obsw_pus_tm_factory.py | 17 +++++++++++ 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/tc/obsw_tc_service20.py b/tc/obsw_tc_service20.py index 40ffc25..924acd7 100644 --- a/tc/obsw_tc_service20.py +++ b/tc/obsw_tc_service20.py @@ -13,70 +13,83 @@ from tc.obsw_tc_service200 import pack_mode_data def pack_service20_test_into(tc_queue: Deque, called_externally: bool = False) -> Deque: + #parameter IDs + parameterID0 = 0 + parameterID1 = 1 + parameterID2 = 2 + if called_externally is False: tc_queue.appendleft(("print", "Testing Service 20")) object_id = g.DUMMY_DEVICE_ID + # set mode normal + tc_queue.appendleft(("print", "Testing Service 20: Set Normal Mode")) + mode_data = pack_mode_data(object_id, 2, 0) + command = PusTelecommand(service=200, subservice=1, ssc=2000, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + #test invalid subservice #use subservice 130 for invalid subservice check, as this is in use for dump reply #(and therefore will never be a valid subservice) - tc_queue.appendleft(("print", "Testing Service 20: Invalid subservice")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=130, ssc=810, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) + #tc_queue.appendleft(("print", "Testing Service 20: Invalid subservice")) + #mode_data = pack_mode_data(object_id, 2, 0) + #command = PusTelecommand(service=20, subservice=130, ssc=810, app_data=mode_data) + #tc_queue.appendleft(command.pack_command_tuple()) #test invalid objectid //TODO: do we have an objectid known to be empty (even in future)? - tc_queue.appendleft(("print", "Testing Service 20: Invalid object ID")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) + #tc_queue.appendleft(("print", "Testing Service 20: Invalid object ID")) + #mode_data = pack_mode_data(object_id, 2, 0) + #command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) + #tc_queue.appendleft(command.pack_command_tuple()) #test invalid parameterID for load - tc_queue.appendleft(("print", "Testing Service 20: Invalid parameter ID for load")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) + #tc_queue.appendleft(("print", "Testing Service 20: Invalid parameter ID for load")) + #mode_data = pack_mode_data(object_id, 2, 0) + #command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) + #tc_queue.appendleft(command.pack_command_tuple()) #test invalid parameterID for dump - tc_queue.appendleft(("print", "Testing Service 20: Invalid parameter ID for dump")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=129, ssc=810, app_data=mode_data) - tc_queue.appendleft(command.pack_command_tuple()) + #tc_queue.appendleft(("print", "Testing Service 20: Invalid parameter ID for dump")) + #mode_data = pack_mode_data(object_id, 2, 0) + #command = PusTelecommand(service=20, subservice=129, ssc=810, app_data=mode_data) + #tc_queue.appendleft(command.pack_command_tuple()) #test checking Load for uint32_t tc_queue.appendleft(("print", "Testing Service 20: Load uint32_t")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) + parameter = struct.pack(">I", parameterID0) + parameter_data = struct.pack(">I", 42) + payload = parameter+parameter_data + command = PusTelecommand(service=20, subservice=128, ssc=2001, app_data=payload) tc_queue.appendleft(command.pack_command_tuple()) #test checking Dump for uint32_t tc_queue.appendleft(("print", "Testing Service 20: Dump uint32_t")) - mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=129, ssc=810, app_data=mode_data) + parameter = struct.pack(">I", parameterID0) + command = PusTelecommand(service=20, subservice=129, ssc=2001, app_data=parameter) tc_queue.appendleft(command.pack_command_tuple()) #test checking Load for int32_t tc_queue.appendleft(("print", "Testing Service 20: Load int32_t")) mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) + command = PusTelecommand(service=20, subservice=128, ssc=2003, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) #test checking Dump for int32_t tc_queue.appendleft(("print", "Testing Service 20: Dump int32_t")) mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=129, ssc=810, app_data=mode_data) + command = PusTelecommand(service=20, subservice=129, ssc=2004, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) #test checking Load for float tc_queue.appendleft(("print", "Testing Service 20: Load float")) mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=128, ssc=810, app_data=mode_data) + command = PusTelecommand(service=20, subservice=128, ssc=2005, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) #test checking Dump for float tc_queue.appendleft(("print", "Testing Service 20: Dump float")) mode_data = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=20, subservice=129, ssc=810, app_data=mode_data) + command = PusTelecommand(service=20, subservice=129, ssc=2006, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) if called_externally is False: diff --git a/tm/obsw_pus_tm_factory.py b/tm/obsw_pus_tm_factory.py index f6b9be1..fe6857a 100644 --- a/tm/obsw_pus_tm_factory.py +++ b/tm/obsw_pus_tm_factory.py @@ -38,6 +38,8 @@ class PusTelemetryFactory(object): return Service8TM(raw_tm_packet) if service_type == 17: return Service17TM(raw_tm_packet) + if service_type == 20: + return Service20TM(raw_tm_packet) if service_type == 200: return Service200TM(raw_tm_packet) print("The service " + str(service_type) + " is not implemented in Telemetry Factory") @@ -100,6 +102,21 @@ class Service17TM(PusTelemetry): super().append_telemetry_column_headers(array) return +class Service20TM(PusTelemetry): + def __init__(self, byte_array): + super().__init__(byte_array) + self.parameter_id = struct.unpack('>I', self._tm_data[0:4])[0] + self.specify_packet_info("Functional Commanding Reply") + + def append_telemetry_content(self, array): + super().append_telemetry_content(array) + array.append(self.parameter_id) + return + + def append_telemetry_column_headers(self, array): + super().append_telemetry_column_headers(array) + array.append("param0_dump_repl") + return class Service200TM(PusTelemetry): def __init__(self, byte_array): -- GitLab