provide function to start put request

This commit is contained in:
Robin Müller 2022-09-08 18:26:36 +02:00
parent 3f0367fdb2
commit 87c7542015
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 136 additions and 3 deletions

View File

@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spacepackets unittests" type="tests" factoryName="Autodetect">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/deps/spacepackets/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/deps/spacepackets/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="tmtccmd unittests" type="tests" factoryName="Autodetect">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/deps/tmtccmd/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/deps/tmtccmd/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>

@ -1 +1 @@
Subproject commit c83e00a67bfb8493e8955cad26d266f9b4033795
Subproject commit 1c0905292e0f2983c723ad19710d27c402fbcf3f

@ -1 +1 @@
Subproject commit 89ac892ea9992df4cf6f662c649b18f49b6c809e
Subproject commit e45e5caca3926c2e800a991f16a6bbdf4c3a77d0

View File

@ -2,13 +2,36 @@
"""TMTC commander for FSFW Example"""
import sys
import time
from pathlib import Path
from typing import Sequence
from spacepackets.cfdp import ConditionCode, TransmissionModes
from spacepackets.ecss import PusVerificator
import tmtccmd
from common_tmtc.common import setup_params, setup_tmtc_handlers, setup_backend
from common_tmtc.common import (
setup_params,
setup_tmtc_handlers,
setup_backend,
EXAMPLE_APID,
)
from config.hook import FsfwHookBase
from spacepackets.util import UnsignedByteField
from tmtccmd import get_console_logger
from tmtccmd.cfdp import (
LocalEntityCfg,
CfdpUserBase,
TransactionId,
RemoteEntityCfg,
RemoteEntityCfgTable,
HostFilestore,
)
from tmtccmd.cfdp.request import PutRequestCfg, PutRequest
from tmtccmd.cfdp.user import (
FileSegmentRecvdParams,
MetadataRecvParams,
TransactionFinishedParams,
)
from tmtccmd.core import BackendRequest
from tmtccmd.logging.pus import (
RegularTmtcLogWrapper,
@ -16,11 +39,87 @@ from tmtccmd.logging.pus import (
TimedLogWhen,
)
from tmtccmd.pus import VerificationWrapper
from tmtccmd.util import ProvidesSeqCount
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.cfdp.handler import DestHandler, SourceHandler
LOGGER = get_console_logger()
class CfdpHandler(CfdpUserBase):
def __init__(
self,
cfg: LocalEntityCfg,
seq_cnt_provider: ProvidesSeqCount,
remote_cfg: Sequence[RemoteEntityCfg],
):
vfs = HostFilestore()
super().__init__(vfs)
self.dest_id = UnsignedByteField(EXAMPLE_APID, 2)
self.remote_cfg_table = RemoteEntityCfgTable()
self.remote_cfg_table.add_remote_entities(remote_cfg)
self.dest_handler = DestHandler(cfg, self, self.remote_cfg_table)
self.source_handler = SourceHandler(cfg, seq_cnt_provider, self)
def put_request_file(
self,
source_path: Path,
dest_path: Path,
trans_mode: TransmissionModes,
closure_requested: bool,
):
put_request_cfg = PutRequestCfg(
destination_id=self.dest_id,
source_file=source_path,
dest_file=dest_path.as_posix(),
trans_mode=trans_mode,
closure_requested=closure_requested,
)
put_request = PutRequest(put_request_cfg)
self.source_handler.put_request(
put_request, self.remote_cfg_table.get_remote_entity(self.dest_id)
)
def transaction_indication(self, transaction_id: TransactionId):
pass
def eof_sent_indication(self, transaction_id: TransactionId):
pass
def transaction_finished_indication(self, params: TransactionFinishedParams):
pass
def metadata_recv_indication(self, params: MetadataRecvParams):
pass
def file_segment_recv_indication(self, params: FileSegmentRecvdParams):
pass
def report_indication(self, transaction_id: TransactionId, status_report: any):
pass
def suspended_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode
):
pass
def resumed_indication(self, transaction_id: TransactionId, progress: int):
pass
def fault_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def abandoned_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def eof_recv_indication(self, transaction_id: TransactionId):
pass
def main():
setup_wrapper = setup_params(FsfwHookBase())
tmtc_logger = RegularTmtcLogWrapper()