diff --git a/comIF/obsw_qemu_com_if.py b/comIF/obsw_qemu_com_if.py index 8cb397ee650911fe2e9a4ab8254a5815041e0a9a..fea94bbe46dcbec810403128713435b7393996f8 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 5b0c9dd260ce4d46c53ced1a06f58c22ee5092cd..b56e627d2155838b46d91966d2f65d741db39b13 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 0e13387cb99b67e257a5b06c7087364b987653e7..236448c2e31ad1bf173c90467ebada51b01f61b0 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 0a93bfd011ac7f6e4da306e565750133a4d73709..9a5e0e3c17cc6ee79d72eeee57e8b2d27294a1b9 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 3772ebc141e86feb5de4173dbe9633866663dd5b..48d84836fc12afce469d45bd2e7cd9cdea8703ad 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 29ea637fde012672c619e1f331a23241bc948c23..9d8d23a7241a251399fcb98be8d7e09e168b4555 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