From aca667248c773138d5a7cf43204eaae9145ac817 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Sep 2022 15:24:23 +0200 Subject: [PATCH] now only args to put req conversion missing --- common.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common.py b/common.py index 98923e1..6b5cc46 100644 --- a/common.py +++ b/common.py @@ -19,7 +19,7 @@ from tmtccmd.cfdp import ( CfdpUserBase, ) from spacepackets.util import UnsignedByteField -from tmtccmd.cfdp.defs import CfdpRequestType +from tmtccmd.cfdp.defs import CfdpRequestType, CfdpStates from tmtccmd.cfdp.handler import SourceHandler, DestHandler from tmtccmd.cfdp.request import PutRequest, PutRequestCfg from tmtccmd.logging import get_current_time_string @@ -164,6 +164,9 @@ class CfdpHandler: return self.dest_handler.pdu_holder return None + def put_request_pending(self) -> bool: + return self.source_handler.states.state != CfdpStates.IDLE + def confirm_dest_packet_sent(self): self.dest_handler.confirm_packet_sent_advance_fsm() @@ -280,11 +283,12 @@ class TcHandler(TcHandlerBase): def handle_cfdp_procedure(self, info: ProcedureHelper): cfdp_procedure = info.to_cfdp_procedure() if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT: - # TODO: Only start put request if there isn't one pending yet. The source handler - # state can probably be used for this. - self.cfdp_in_ccsds_wrapper.handler.put_request( - cfdp_procedure.request_wrapper.to_put_request() - ) + if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending(): + put_req = cfdp_procedure.request_wrapper.to_put_request() + LOGGER.info(f"Starting put request {put_req}") + # TODO: Only start put request if there isn't one pending yet. The source handler + # state can probably be used for this. + self.cfdp_in_ccsds_wrapper.handler.put_request(put_req) pass pass