correct code is now reached

This commit is contained in:
Robin Müller 2022-09-12 09:39:37 +02:00
parent 99ccd04b2a
commit 845ee041d4
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -84,7 +84,8 @@ from tmtccmd.config import (
CoreServiceList,
SetupWrapper,
SetupParams,
PreArgsParsingWrapper, params_to_procedure_conversion,
PreArgsParsingWrapper,
params_to_procedure_conversion,
)
from common_tmtc.pus_tm.factory_hook import pus_factory_hook
@ -215,19 +216,18 @@ class CfdpHandler:
seq_cnt_provider: ProvidesSeqCount,
remote_cfgs: Sequence[RemoteEntityCfg],
):
self.dest_id = UnsignedByteField(EXAMPLE_PUS_APID, 2)
self.remote_cfg_table = RemoteEntityCfgTable()
self.remote_cfg_table.add_configs(remote_cfgs)
self.dest_handler = DestHandler(cfg, user, self.remote_cfg_table)
self.source_handler = SourceHandler(cfg, seq_cnt_provider, user)
def put_request(self, request: PutRequest):
if self.remote_cfg_table.get_cfg(request.cfg.destination_id):
if not self.remote_cfg_table.get_cfg(request.cfg.destination_id):
raise ValueError(
f"No remote CFDP config found for entity ID {request.cfg.destination_id}"
)
self.source_handler.put_request(
request, self.remote_cfg_table.get_cfg(self.dest_id)
request, self.remote_cfg_table.get_cfg(request.cfg.destination_id)
)
def pull_next_dest_packet(self) -> Optional[PduHolder]:
@ -311,6 +311,7 @@ class TcHandler(TcHandlerBase):
raw_logger: RawTmtcTimedLogWrapper,
):
super().__init__()
self.cfdp_dest_id = CFDP_REMOTE_ENTITY_ID
self.seq_count_provider = seq_count_provider
self.pus_verificator = pus_verificator
self.file_logger = file_logger
@ -356,21 +357,9 @@ class TcHandler(TcHandlerBase):
cfdp_procedure = info.to_cfdp_procedure()
if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT:
if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending():
# put_req = cfdp_procedure.request_wrapper.to_put_request()
with open("/tmp/hello.txt") as of:
of.write("Hello first CFDP file")
# TODO: Replace hardcoded put request if the request works
put_request_cfg = PutRequestCfg(
destination_id=self.cfdp_in_ccsds_wrapper.handler.dest_id,
source_file=Path("/tmp/hello.txt"),
dest_file="/tmp/hello-created-by-dest.txt",
closure_requested=False,
trans_mode=TransmissionModes.UNACKNOWLEDGED,
)
put_req = PutRequest(put_request_cfg)
put_req = cfdp_procedure.request_wrapper.to_put_request()
put_req.cfg.destination_id = self.cfdp_dest_id
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
@ -491,9 +480,7 @@ def setup_backend(
tc_handler: TcHandler,
ccsds_handler: CcsdsTmHandler,
) -> BackendBase:
init_proc = params_to_procedure_conversion(
setup_wrapper.proc_param_wrapper
)
init_proc = params_to_procedure_conversion(setup_wrapper.proc_param_wrapper)
tmtc_backend = tmtccmd.create_default_tmtc_backend(
setup_wrapper=setup_wrapper,
tm_handler=ccsds_handler,