more generic PDU packing approach
This commit is contained in:
parent
51871a887f
commit
4a9ed5aad0
51
common.py
51
common.py
@ -7,7 +7,7 @@ from spacepackets import SpacePacket, SpacePacketHeader
|
||||
from spacepackets.cfdp import (
|
||||
TransmissionModes,
|
||||
ChecksumTypes,
|
||||
ConditionCode,
|
||||
ConditionCode, PduHolder, DirectiveTypes,
|
||||
)
|
||||
from spacepackets.cfdp.pdu import MetadataPdu, FileDataPdu
|
||||
from tmtccmd.cfdp import (
|
||||
@ -248,35 +248,28 @@ class TcHandler(TcHandlerBase):
|
||||
)
|
||||
self.cfdp_in_ccsds_wrapper.handler.cfdp_handler.put_request(put_req)
|
||||
self.cfdp_handler_started = True
|
||||
(
|
||||
pdu_holder,
|
||||
packet,
|
||||
) = self.cfdp_in_ccsds_wrapper.handler.pull_next_source_packet()
|
||||
self.queue_helper.add_ccsds_tc(packet)
|
||||
self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent()
|
||||
metadata = cast(MetadataPdu, pdu_holder.to_metadata_pdu())
|
||||
self.queue_helper.add_log_cmd(
|
||||
f"CFDP Source: Sending Metadata PDU for file with size {metadata.file_size}"
|
||||
)
|
||||
(
|
||||
pdu_holder,
|
||||
packet,
|
||||
) = self.cfdp_in_ccsds_wrapper.handler.pull_next_source_packet()
|
||||
fd_pdu = cast(FileDataPdu, pdu_holder.to_file_data_pdu())
|
||||
self.queue_helper.add_ccsds_tc(packet)
|
||||
self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent()
|
||||
self.queue_helper.add_log_cmd(
|
||||
f"CFDP Source: Sending File Data PDU for segment at offset {fd_pdu.offset} "
|
||||
f"with length {len(fd_pdu.file_data)}"
|
||||
)
|
||||
(
|
||||
pdu_holder,
|
||||
packet,
|
||||
) = self.cfdp_in_ccsds_wrapper.handler.pull_next_source_packet()
|
||||
self.queue_helper.add_log_cmd(f"CFDP Source: Sending EOF PDU")
|
||||
self.queue_helper.add_ccsds_tc(packet)
|
||||
|
||||
self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent()
|
||||
for source_pair, dest_pair in self.cfdp_in_ccsds_wrapper.handler:
|
||||
pdu, sp = source_pair
|
||||
pdu = cast(PduHolder, pdu)
|
||||
if pdu.is_file_directive:
|
||||
if pdu.pdu_directive_type == DirectiveTypes.METADATA_PDU:
|
||||
metadata = pdu.to_metadata_pdu()
|
||||
self.queue_helper.add_log_cmd(
|
||||
f"CFDP Source: Sending Metadata PDU for file with size "
|
||||
f"{metadata.file_size}"
|
||||
)
|
||||
elif pdu.pdu_directive_type == DirectiveTypes.EOF_PDU:
|
||||
eof = pdu.to_eof_pdu()
|
||||
self.queue_helper.add_log_cmd(f"CFDP Source: Sending EOF PDU")
|
||||
else:
|
||||
fd_pdu = pdu.to_file_data_pdu()
|
||||
self.queue_helper.add_log_cmd(
|
||||
f"CFDP Source: Sending File Data PDU for segment at offset "
|
||||
f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}"
|
||||
)
|
||||
self.queue_helper.add_ccsds_tc(sp)
|
||||
self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent()
|
||||
self.cfdp_in_ccsds_wrapper.handler.source_handler.state_machine()
|
||||
|
||||
def send_cb(self, params: SendCbParams):
|
||||
|
Loading…
x
Reference in New Issue
Block a user