diff --git a/config/obsw_com_config.py b/config/obsw_com_config.py index e4e2449cf7211c5c8232535992362b3f5f0413d9..9fcfc1877be51c36771bf42c9a238b1f07393f3a 100644 --- a/config/obsw_com_config.py +++ b/config/obsw_com_config.py @@ -47,8 +47,8 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio communication_interface = DummyComIF(tmtc_printer=tmtc_printer) if not communication_interface.valid: LOGGER.warning("Invalid communication interface!") - return None - communication_interface.initialize() + else: + communication_interface.initialize() return communication_interface except (IOError, OSError): LOGGER.error("Error setting up communication interface") diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index 7d154656d97b31cc0039e1a207055087901a43c6..eb88c13e5af5464114aec43dc843ea018a4b6e4b 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -123,16 +123,12 @@ class TmTcHandler: com_interface=self.communication_interface, tm_timeout=g.G_TM_TIMEOUT, tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR ) - self.initialize_com_if_and_listener() - atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface) - - def initialize_com_if_and_listener(self): - if not self.communication_interface.valid: + if self.communication_interface.valid: + self.tm_listener.start() + else: LOGGER.info("No communication interface set for now") LOGGER.info("TM listener will not be started") - return - - self.tm_listener.start() + atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface) def perform_operation(self): """ @@ -185,6 +181,8 @@ class TmTcHandler: service_queue = deque() service_queue_packer = ServiceQueuePacker() service_queue_packer.pack_service_queue(g.G_SERVICE, service_queue) + if not self.communication_interface.valid: + return LOGGER.info("Performing service command operation") sender_and_receiver = SequentialCommandSenderReceiver( com_interface=self.communication_interface, tmtc_printer=self.tmtc_printer,