tmtccmd v7.0.0 #254
@ -1,8 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from eive_tmtc.config.definitions import CFDP_APID
|
from eive_tmtc.config.definitions import CFDP_APID
|
||||||
from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE
|
from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE
|
||||||
from spacepackets.cfdp import PduFactory, PduType, DirectiveType
|
from spacepackets.cfdp import PduFactory, PduType
|
||||||
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
|
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
|
||||||
from tmtccmd.tmtc import SpecificApidHandlerBase
|
from tmtccmd.tmtc import SpecificApidHandlerBase
|
||||||
|
|
||||||
@ -11,17 +12,18 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class CfdpInCcsdsWrapper(SpecificApidHandlerBase):
|
class CfdpInCcsdsWrapper(SpecificApidHandlerBase):
|
||||||
def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler):
|
def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler):
|
||||||
super().__init__(CFDP_APID, None)
|
|
||||||
self.handler = cfdp_in_ccsds_handler
|
self.handler = cfdp_in_ccsds_handler
|
||||||
|
super().__init__(CFDP_APID, None)
|
||||||
|
|
||||||
def handle_tm(self, packet: bytes, _user_args: any):
|
def handle_tm(self, packet: bytes, _user_args: Any):
|
||||||
# Ignore the space packet header. Its only purpose is to use the same protocol and
|
# Ignore the space packet header. Its only purpose is to use the same protocol and
|
||||||
# have a seaprate APID for space packets. If this function is called, the APID is correct.
|
# have a seaprate APID for space packets. If this function is called, the APID is correct.
|
||||||
pdu = packet[SPACE_PACKET_HEADER_SIZE:]
|
pdu = packet[SPACE_PACKET_HEADER_SIZE:]
|
||||||
pdu_base = PduFactory.from_raw(pdu)
|
generic_pdu = PduFactory.from_raw(pdu)
|
||||||
if pdu_base.pdu_type == PduType.FILE_DATA:
|
assert generic_pdu is not None
|
||||||
|
if generic_pdu.pdu_type == PduType.FILE_DATA:
|
||||||
_LOGGER.info("Received File Data PDU")
|
_LOGGER.info("Received File Data PDU")
|
||||||
else:
|
else:
|
||||||
directive_type = DirectiveType(pdu_base.directive_type)
|
directive_type = PduFactory.pdu_directive_type(pdu)
|
||||||
_LOGGER.info(f"Received File Directive PDU with type {directive_type!r}")
|
_LOGGER.info(f"Received File Directive PDU with type {directive_type!r}")
|
||||||
self.handler.insert_pdu_packet(pdu_base)
|
self.handler.insert_pdu_packet(generic_pdu)
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from spacepackets.cfdp import ConditionCode
|
from spacepackets.cfdp import ConditionCode
|
||||||
|
from spacepackets.util import UnsignedByteField
|
||||||
from tmtccmd.cfdp import CfdpUserBase, TransactionId
|
from tmtccmd.cfdp import CfdpUserBase, TransactionId
|
||||||
|
from tmtccmd.cfdp.mib import CheckTimerProvider, Countdown, EntityType
|
||||||
from tmtccmd.cfdp.user import (
|
from tmtccmd.cfdp.user import (
|
||||||
TransactionFinishedParams,
|
TransactionFinishedParams,
|
||||||
MetadataRecvParams,
|
MetadataRecvParams,
|
||||||
@ -11,6 +14,16 @@ from tmtccmd.cfdp.user import (
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class EiveCheckTimerProvider(CheckTimerProvider):
|
||||||
|
def provide_check_timer(
|
||||||
|
self,
|
||||||
|
local_entity_id: UnsignedByteField,
|
||||||
|
remote_entity_id: UnsignedByteField,
|
||||||
|
entity_type: EntityType,
|
||||||
|
) -> Countdown:
|
||||||
|
return Countdown(timedelta(seconds=5.0))
|
||||||
|
|
||||||
|
|
||||||
class EiveCfdpUser(CfdpUserBase):
|
class EiveCfdpUser(CfdpUserBase):
|
||||||
def transaction_indication(self, transaction_id: TransactionId):
|
def transaction_indication(self, transaction_id: TransactionId):
|
||||||
_LOGGER.info(f"CFDP User: Start of File {transaction_id}")
|
_LOGGER.info(f"CFDP User: Start of File {transaction_id}")
|
||||||
|
9
tmtcc.py
9
tmtcc.py
@ -14,7 +14,8 @@ from spacepackets.cfdp import (
|
|||||||
from spacepackets.ecss import PusVerificator
|
from spacepackets.ecss import PusVerificator
|
||||||
from spacepackets.version import get_version as get_sp_version
|
from spacepackets.version import get_version as get_sp_version
|
||||||
from tmtccmd import BackendBase
|
from tmtccmd import BackendBase
|
||||||
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
|
from tmtccmd.cfdp.handler import RemoteEntityCfgTable
|
||||||
|
from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler
|
||||||
from tmtccmd.cfdp.mib import (
|
from tmtccmd.cfdp.mib import (
|
||||||
IndicationCfg,
|
IndicationCfg,
|
||||||
LocalEntityCfg,
|
LocalEntityCfg,
|
||||||
@ -45,7 +46,7 @@ from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider
|
|||||||
from eive_tmtc import APP_LOGGER
|
from eive_tmtc import APP_LOGGER
|
||||||
from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler
|
from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler
|
||||||
from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper
|
from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper
|
||||||
from eive_tmtc.cfdp.user import EiveCfdpUser
|
from eive_tmtc.cfdp.user import EiveCfdpUser, EiveCheckTimerProvider
|
||||||
from eive_tmtc.config.definitions import (
|
from eive_tmtc.config.definitions import (
|
||||||
CFDP_APID,
|
CFDP_APID,
|
||||||
CFDP_LOCAL_ENTITY_ID,
|
CFDP_LOCAL_ENTITY_ID,
|
||||||
@ -168,6 +169,7 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
|
|||||||
crc_type=ChecksumType.CRC_32,
|
crc_type=ChecksumType.CRC_32,
|
||||||
default_transmission_mode=TransmissionMode.UNACKNOWLEDGED,
|
default_transmission_mode=TransmissionMode.UNACKNOWLEDGED,
|
||||||
)
|
)
|
||||||
|
check_timer_provider = EiveCheckTimerProvider()
|
||||||
cfdp_seq_count_provider = FileSeqCountProvider(
|
cfdp_seq_count_provider = FileSeqCountProvider(
|
||||||
max_bit_width=16, file_name=Path("seqcnt_cfdp_transaction.txt")
|
max_bit_width=16, file_name=Path("seqcnt_cfdp_transaction.txt")
|
||||||
)
|
)
|
||||||
@ -177,7 +179,8 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
|
|||||||
cfdp_user = EiveCfdpUser()
|
cfdp_user = EiveCfdpUser()
|
||||||
cfdp_in_ccsds_handler = CfdpInCcsdsHandler(
|
cfdp_in_ccsds_handler = CfdpInCcsdsHandler(
|
||||||
cfg=cfdp_cfg,
|
cfg=cfdp_cfg,
|
||||||
remote_cfgs=[remote_cfg, self_as_remote],
|
check_timer_provider=check_timer_provider,
|
||||||
|
remote_cfg_table=RemoteEntityCfgTable([remote_cfg, self_as_remote]),
|
||||||
ccsds_apid=CFDP_APID,
|
ccsds_apid=CFDP_APID,
|
||||||
ccsds_seq_cnt_provider=cfdp_ccsds_seq_count_provider,
|
ccsds_seq_cnt_provider=cfdp_ccsds_seq_count_provider,
|
||||||
cfdp_seq_cnt_provider=cfdp_seq_count_provider,
|
cfdp_seq_cnt_provider=cfdp_seq_count_provider,
|
||||||
|
Loading…
Reference in New Issue
Block a user