From f0cab9eaabdb49c27ed7e00870f54efef6335500 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sun, 26 Apr 2020 21:04:41 +0200 Subject: [PATCH] some bugfixes --- comIF/obsw_dummy_com_if.py | 19 +++++++++++++++++-- .../obsw_sequential_sender_receiver.py | 6 +++--- tc/obsw_pus_tc_base.py | 15 ++++++++------- tc/obsw_pus_tc_packer.py | 6 +++--- tm/obsw_pus_tm_creator.py | 9 +++++---- tm/obsw_tm_service_1.py | 6 +++--- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/comIF/obsw_dummy_com_if.py b/comIF/obsw_dummy_com_if.py index ac4acc3..20c20f9 100644 --- a/comIF/obsw_dummy_com_if.py +++ b/comIF/obsw_dummy_com_if.py @@ -18,6 +18,9 @@ class DummyComIF(CommunicationInterface): super().__init__(tmtc_printer) self.service_sent = 0 self.reply_pending = False + self.ssc = 0 + self.tc_ssc = 0 + self.tc_packet_id = 0 def close(self) -> None: pass @@ -32,14 +35,26 @@ class DummyComIF(CommunicationInterface): def receive_telemetry(self, parameters: any = 0): if self.service_sent == 17 or self.service_sent == 5 and self.reply_pending: - tm_packer = Service1TmPacked(subservice=1, ssc=0) + tm_list = [] + tm_packer = Service1TmPacked(subservice=1, ssc=self.ssc, tc_packet_id=self.tc_packet_id, + tc_ssc=self.tc_ssc) + + tm_packet_raw = tm_packer.pack() + tm_packet = PusTelemetryFactory.create(tm_packet_raw) + tm_list.append(tm_packet) + tm_packer = Service1TmPacked(subservice=7, ssc=self.ssc, tc_packet_id=self.tc_packet_id, + tc_ssc=self.tc_ssc) tm_packet_raw = tm_packer.pack() tm_packet = PusTelemetryFactory.create(tm_packet_raw) + tm_list.append(tm_packet) self.reply_pending = False - return [tm_packet] + self.ssc += 1 + return tm_list return [] def send_telecommand(self, tc_packet: PusTelecommand, tc_packet_info: PusTcInfoT = None) -> None: if isinstance(tc_packet_info, dict) and tc_packet_info.__len__() > 0: self.service_sent = tc_packet_info[TcDictionaryKeys.SERVICE] + self.tc_packet_id = tc_packet_info[TcDictionaryKeys.PACKET_ID] + self.tc_ssc = tc_packet_info[TcDictionaryKeys.SSC] self.reply_pending = True diff --git a/sendreceive/obsw_sequential_sender_receiver.py b/sendreceive/obsw_sequential_sender_receiver.py index f0b044a..0bce546 100644 --- a/sendreceive/obsw_sequential_sender_receiver.py +++ b/sendreceive/obsw_sequential_sender_receiver.py @@ -64,10 +64,10 @@ class SequentialCommandSenderReceiver(CommandSenderReceiver): if not self.__mode_op_finished: self._tm_listener.mode_op_finished.set() self.__mode_op_finished = True - logger.info("Sequential SenderReceiver: All replies received!") + logger.info("SequentialSenderReceiver: All replies received!") if g.G_PRINT_TO_FILE: - logger.info("Sequential SenderReceiver: Exporting output to log file.") - self._tmtc_printer.print_to_file("log/tmtc_log.txt", True) + logger.info("SequentialSenderReceiver: Exporting output to log file.") + self._tmtc_printer.print_file_buffer_list_to_file("log/tmtc_log.txt", True) def __perform_next_tc_send(self): if self._tm_listener.replyEvent.is_set(): diff --git a/tc/obsw_pus_tc_base.py b/tc/obsw_pus_tc_base.py index b4678e5..9f114fe 100644 --- a/tc/obsw_pus_tc_base.py +++ b/tc/obsw_pus_tc_base.py @@ -11,7 +11,7 @@ class TcDictionaryKeys(Enum): SERVICE = 1 SUBSERVICE = 2 SSC = 3 - PACKED_ID = 4 + PACKET_ID = 4 DATA = 5 @@ -37,10 +37,11 @@ class PusTelecommand: """ packet_type = 1 data_field_header_flag = 1 - self.packet_id = [0x0, 0x0] - self.packet_id[0] = ((version << 5) & 0xE0) | ((packet_type & 0x01) << 4) | \ + self.packet_id_bytes = [0x0, 0x0] + self.packet_id_bytes[0] = ((version << 5) & 0xE0) | ((packet_type & 0x01) << 4) | \ ((data_field_header_flag & 0x01) << 3) | ((apid & 0x700) >> 8) - self.packet_id[1] = apid & 0xFF + self.packet_id_bytes[1] = apid & 0xFF + self.packet_id = (self.packet_id_bytes[0] << 8) | self.packet_id_bytes[1] self.ssc = ssc self.psc = (ssc & 0x3FFF) | (0xC0 << 8) self.pus_version_and_ack_byte = 0b00011111 @@ -89,8 +90,8 @@ class PusTelecommand: Serializes the TC data fields into a bytearray. """ data_to_pack = bytearray() - data_to_pack.append(self.packet_id[0]) - data_to_pack.append(self.packet_id[1]) + data_to_pack.append(self.packet_id_bytes[0]) + data_to_pack.append(self.packet_id_bytes[1]) data_to_pack.append((self.psc & 0xFF00) >> 8) data_to_pack.append(self.psc & 0xFF) length = self.get_data_length() @@ -116,7 +117,7 @@ class PusTelecommand: TcDictionaryKeys.SERVICE: self.service, TcDictionaryKeys.SUBSERVICE: self.subservice, TcDictionaryKeys.SSC: self.ssc, - TcDictionaryKeys.PACKED_ID: self.packet_id, + TcDictionaryKeys.PACKET_ID: self.packet_id, TcDictionaryKeys.DATA: self.app_data } return tc_information diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index 81ea745..adbee62 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -92,13 +92,13 @@ def pack_service9_test_into(tc_queue: TcQueueT) -> TcQueueT: print("Time Code 3 :" + str(time_test3) + "\r") # time setting tc_queue.appendleft(("print", "\r\nTesting Service 9: Testing timecode A")) - command = PusTelecommand(service=9, subservice=128, ssc=900, app_data=time_test1) + command = PusTelecommand(service=9, subservice=128, ssc=900, app_data=bytearray(time_test1)) tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(("print", "\r\nTesting Service 9: Testing timecode B")) - command = PusTelecommand(service=9, subservice=128, ssc=910, app_data=time_test2) + command = PusTelecommand(service=9, subservice=128, ssc=910, app_data=bytearray(time_test2)) tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(("print", "\r\nTesting Service 9: Testing timecode Current Time")) - command = PusTelecommand(service=9, subservice=128, ssc=920, app_data=time_test3) + 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(("print", "\r")) diff --git a/tm/obsw_pus_tm_creator.py b/tm/obsw_pus_tm_creator.py index 1f768b2..1ffdee3 100644 --- a/tm/obsw_pus_tm_creator.py +++ b/tm/obsw_pus_tm_creator.py @@ -19,10 +19,11 @@ class PusTelemetryCreator(PusTelemetry): packet_type = 0 # specified in standard data_field_header_flag = 1 - self.packet_id = [0x0, 0x0] - self.packet_id[0] = ((version << 5) & 0xE0) | ((packet_type & 0x01) << 4) | \ + self.packet_id_bytes = [0x0, 0x0] + self.packet_id_bytes[0] = ((version << 5) & 0xE0) | ((packet_type & 0x01) << 4) | \ ((data_field_header_flag & 0x01) << 3) | ((apid & 0x700) >> 8) - self.packet_id[1] = apid & 0xFF + self.packet_id_bytes[1] = apid & 0xFF + self.packet_id = (self.packet_id_bytes[0] << 8) | self.packet_id_bytes[1] self.ssc = ssc self.psc = (ssc & 0x3FFF) | (0b11 << 16) self.pus_version_and_ack_byte = 0b00011111 @@ -41,7 +42,7 @@ class PusTelemetryCreator(PusTelemetry): def pack(self) -> bytearray: tm_packet_raw = bytearray() # PUS Header - tm_packet_raw.extend(self.packet_id) + tm_packet_raw.extend(self.packet_id_bytes) tm_packet_raw.append((self.psc & 0xFF00) >> 8) tm_packet_raw.append(self.psc & 0xFF) source_length = self.get_source_data_length() diff --git a/tm/obsw_tm_service_1.py b/tm/obsw_tm_service_1.py index 952e631..3088301 100644 --- a/tm/obsw_tm_service_1.py +++ b/tm/obsw_tm_service_1.py @@ -87,10 +87,10 @@ class Service1TM(PusTelemetry): class Service1TmPacked(PusTelemetryCreator): - def __init__(self, subservice: int, ssc: int=0, tc_packed_id: int=0, tc_ssc: int=0): + def __init__(self, subservice: int, ssc: int=0, tc_packet_id: int=0, tc_ssc: int=0): source_data = bytearray() - source_data.append((tc_packed_id & 0xFF00) >> 8) - source_data.append(tc_packed_id & 0xFF) + source_data.append((tc_packet_id & 0xFF00) >> 8) + source_data.append(tc_packet_id & 0xFF) tc_psc = (tc_ssc & 0x3FFF) | (0b11 << 16) source_data.append((tc_psc & 0xFF00) >> 8) source_data.append(tc_psc & 0xFF) -- GitLab