From 100d8aa59b91e8d6ad6a00621bcf000d3b9607fa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Mon, 27 Apr 2020 23:52:47 +0200 Subject: [PATCH] bugfix --- comIF/obsw_qemu_com_if.py | 21 -------- .../obsw_sequential_sender_receiver.py | 2 + sendreceive/obsw_tm_listener.py | 1 - tm/obsw_pus_tm_base.py | 4 +- tm/obsw_pus_tm_creator.py | 2 +- utility/obsw_tmtc_printer.py | 50 +++++++++---------- 6 files changed, 30 insertions(+), 50 deletions(-) diff --git a/comIF/obsw_qemu_com_if.py b/comIF/obsw_qemu_com_if.py index 8cb397e..fea94bb 100755 --- a/comIF/obsw_qemu_com_if.py +++ b/comIF/obsw_qemu_com_if.py @@ -486,24 +486,3 @@ class UsartProtocol(asyncio.Protocol): self.conn.respd[frame.seq] = frame self.conn.respc.notify_all() - -async def main(): - # Instantiate the connection classes we need. The connections are not - # opened automatically. Use '.open()' or 'async with machine as m'. - usart = Usart(QEMU_ADDR_AT91_USART0) - - await usart.open() - - while True: - command = PUSTelecommand(17, 1) - await usart.write(command.pack()) - usart.inject_timeout_error() - - response = await usart.read(68) - - test = PUSTelemetryFactory(response) - print(test.packTmInformation()) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/sendreceive/obsw_sequential_sender_receiver.py b/sendreceive/obsw_sequential_sender_receiver.py index 5b0c9dd..b56e627 100644 --- a/sendreceive/obsw_sequential_sender_receiver.py +++ b/sendreceive/obsw_sequential_sender_receiver.py @@ -45,6 +45,8 @@ class SequentialCommandSenderReceiver(CommandSenderReceiver): """ self._tm_listener.mode_id = g.ModeList.ServiceTestMode self._tm_listener.event_mode_change.set() + # tiny delay for tm listener + time.sleep(0.1) self.__send_and_receive_first_packet() # this flag is set in the separate thread ! try: diff --git a/sendreceive/obsw_tm_listener.py b/sendreceive/obsw_tm_listener.py index 0e13387..236448c 100644 --- a/sendreceive/obsw_tm_listener.py +++ b/sendreceive/obsw_tm_listener.py @@ -166,7 +166,6 @@ class TmListener: if self.lock_listener.acquire(True, timeout=1): tm_list = self.com_interface.receive_telemetry() self.__tm_packet_queue.append(tm_list) - LOGGER.debug(tm_list) else: LOGGER.critical("TmListener: Blocked on lock acquisition for longer than 1 second!") self.lock_listener.release() diff --git a/tm/obsw_pus_tm_base.py b/tm/obsw_pus_tm_base.py index 0a93bfd..9a5e0e3 100644 --- a/tm/obsw_pus_tm_base.py +++ b/tm/obsw_pus_tm_base.py @@ -175,11 +175,13 @@ class PusTelemetry: """ return self._pus_header.source_sequence_count + def return_full_packet_string(self): + return self.return_data_string(self._packet_raw, len(self._packet_raw)) + def print_full_packet_string(self): """ Print the full TM packet in a clean format. """ - logger.info(self.return_data_string(self._packet_raw, len(self._packet_raw))) def print_source_data(self): diff --git a/tm/obsw_pus_tm_creator.py b/tm/obsw_pus_tm_creator.py index 3772ebc..48d8483 100644 --- a/tm/obsw_pus_tm_creator.py +++ b/tm/obsw_pus_tm_creator.py @@ -36,7 +36,7 @@ class PusTelemetryCreator(PusTelemetry): 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.psc = (ssc & 0x3FFF) | (0xC0 << 8) self.pus_version_and_ack_byte = 0b00011111 # NOTE: In PUS-C, the PUS Version is 2 and specified for the first 4 bits. diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py index 29ea637..9d8d23a 100644 --- a/utility/obsw_tmtc_printer.py +++ b/utility/obsw_tmtc_printer.py @@ -61,6 +61,7 @@ class TmTcPrinter: :return: """ print() + LOGGER.debug(packet.return_full_packet_string()) if self.display_mode == DisplayMode.SHORT: self.__handle_short_print(packet) else: @@ -202,29 +203,6 @@ class TmTcPrinter: + tm_packet.return_source_data() LOGGER.info(self.__print_buffer) - def print_data(self, byte_array: bytearray): - """ - :param byte_array: - :return: None - """ - string = self.return_data_string(byte_array) - LOGGER.info(string) - - @staticmethod - def return_data_string(byte_array: bytearray) -> str: - """ - Converts a bytearray to string format for printing - :param byte_array: - :return: - """ - str_to_print = "[" - for byte in byte_array: - str_to_print += str(hex(byte)) + " , " - str_to_print = str_to_print.rstrip(' ') - str_to_print = str_to_print.rstrip(',') - str_to_print += ']' - return str_to_print - def print_string(self, string: str, add_cr_to_file_buffer: bool = False): """ Print a string and adds it to the file buffer. @@ -251,8 +229,6 @@ class TmTcPrinter: else: self.__file_buffer += self.__print_buffer + "\r\n" - - def add_print_buffer_to_buffer_list(self): """ Add the current print buffer to the buffer list """ self.file_buffer_list.append(self.__file_buffer) @@ -358,8 +334,30 @@ class TmTcPrinter: str(tc_packet_info[TcDictionaryKeys.SUBSERVICE]) + "] with SSC " + \ str(tc_packet_info[TcDictionaryKeys.SSC]) + " sent with data " + \ self.return_data_string(tc_packet_info[TcDictionaryKeys.DATA]) - LOGGER.info(self.__print_buffer) self.add_print_buffer_to_file_buffer() except TypeError as error: LOGGER.error("TMTC Printer: Type Error! Traceback: %s", error) + + def print_data(self, byte_array: bytearray): + """ + :param byte_array: + :return: None + """ + string = self.return_data_string(byte_array) + LOGGER.info(string) + + @staticmethod + def return_data_string(byte_array: bytearray) -> str: + """ + Converts a bytearray to string format for printing + :param byte_array: + :return: + """ + str_to_print = "[" + for byte in byte_array: + str_to_print += str(hex(byte)) + " , " + str_to_print = str_to_print.rstrip(' ') + str_to_print = str_to_print.rstrip(',') + str_to_print += ']' + return str_to_print -- GitLab