diff --git a/examples/cfdp-cli-udp/common.py b/examples/cfdp-cli-udp/common.py index 62ad3d7d..4de2da91 100644 --- a/examples/cfdp-cli-udp/common.py +++ b/examples/cfdp-cli-udp/common.py @@ -155,6 +155,7 @@ def transaction_finished_indication(self, params: TransactionFinishedParams): ProxyPutResponseParams.from_finished_params(params.finished_params) ).to_generic_msg_to_user_tlv() originating_id = self.active_proxy_put_reqs.get(params.transaction_id) + assert originating_id is not None put_req = PutRequest( destination_id=originating_id.source_id, source_file=None, @@ -187,9 +188,9 @@ def _handle_msgs_to_user( ): for msg_to_user in msgs_to_user: if msg_to_user.is_reserved_cfdp_message(): - self._handle_reserved_cfdp_message( - transaction_id, msg_to_user.to_reserved_msg_tlv() - ) + reserved_msg_tlv = msg_to_user.to_reserved_msg_tlv() + assert reserved_msg_tlv is not None + self._handle_reserved_cfdp_message(transaction_id, reserved_msg_tlv) else: _LOGGER.info(f"Received custom message to user: {msg_to_user}") @@ -315,10 +316,10 @@ def run(self): self.periodic_operation() time.sleep(self.sleep_time) - def periodic_operation(self) -> bool: + def periodic_operation(self): while True: next_packet = self.poll_next_udp_packet() - if next_packet is None: + if next_packet is None or next_packet.pdu is None: break # Perform PDU routing. packet_dest = get_packet_destination(next_packet.pdu) @@ -335,7 +336,7 @@ def poll_next_udp_packet(self) -> Optional[PduHolder]: return PduFactory.from_raw_to_holder(data) return None - def send_packets(self) -> bool: + def send_packets(self): while True: try: next_tm = self.tm_queue.get(False) @@ -380,6 +381,7 @@ def _idle_handling(self) -> bool: ) else: self.source_handler.put_request(put_req) + return True except Empty: return False diff --git a/examples/cfdp-cli-udp/local.py b/examples/cfdp-cli-udp/local.py index 9ecdc632..5ff70ee2 100755 --- a/examples/cfdp-cli-udp/local.py +++ b/examples/cfdp-cli-udp/local.py @@ -58,9 +58,8 @@ def main(): parser.add_argument("-v", "--verbose", action="count", default=0) add_cfdp_procedure_arguments(parser) args = parser.parse_args() - if args.verbose == 0: - logging_level = logging.INFO - elif args.verbose >= 1: + logging_level = logging.INFO + if args.verbose >= 1: logging_level = logging.DEBUG if args.source is not None and args.target is not None: # Generate a put request from the CLI arguments. @@ -114,10 +113,14 @@ def main(): TM_QUEUE, ) + # Address Any to accept CFDP packets from other address than localhost. + local_addr = "0.0.0.0" + # Localhost default address + remote_addr = "127.0.0.1" udp_server = UdpServer( 0.1, - ("127.0.0.1", LOCAL_PORT), - ("127.0.0.1", REMOTE_PORT), + (local_addr, LOCAL_PORT), + (remote_addr, REMOTE_PORT), TM_QUEUE, SOURCE_ENTITY_QUEUE, DEST_ENTITY_QUEUE, diff --git a/examples/cfdp-cli-udp/remote.py b/examples/cfdp-cli-udp/remote.py index fe7338e0..a11b6503 100755 --- a/examples/cfdp-cli-udp/remote.py +++ b/examples/cfdp-cli-udp/remote.py @@ -50,9 +50,8 @@ def main(): parser = argparse.ArgumentParser(prog="CFDP Remote Entity Application") parser.add_argument("-v", "--verbose", action="count", default=0) args = parser.parse_args() - if args.verbose == 0: - logging_level = logging.INFO - elif args.verbose >= 1: + logging_level = logging.INFO + if args.verbose >= 1: logging_level = logging.DEBUG basicConfig(level=logging_level) @@ -96,10 +95,14 @@ def main(): TM_QUEUE, ) + # Address Any to accept CFDP packets from other address than localhost. + local_addr = "0.0.0.0" + # Localhost default address + remote_addr = "127.0.0.1" udp_server = UdpServer( 0.1, - ("127.0.0.1", REMOTE_PORT), - ("127.0.0.1", LOCAL_PORT), + (local_addr, REMOTE_PORT), + (remote_addr, LOCAL_PORT), TM_QUEUE, SOURCE_ENTITY_QUEUE, DEST_ENTITY_QUEUE,