29 if (this->m_engine !=
nullptr) {
37 this->m_engine =
static_cast<Engine*
>(allocator.
allocate(memId, engineSize));
39 (void)
new (this->m_engine)
Engine(
this);
40 this->m_engine->
init(allocator, memId);
43 this->m_allocator = &allocator;
44 this->m_allocatorId = memId;
52 this->m_fileInQueueDepth = fileQueueDepth;
55 static_cast<FwSizeType>(
sizeof(FileInRequest)));
66 if ((this->m_allocator !=
nullptr) && (this->m_engine !=
nullptr)) {
70 this->m_allocator->
deallocate(this->m_allocatorId, this->m_engine);
71 this->m_engine =
nullptr;
79 void CfdpManager ::run1Hz_handler(
FwIndexType portNum, U32 context) {
84 this->drainFileInQueue();
86 this->m_engine->
cycle();
92 void CfdpManager ::drainFileInQueue() {
96 for (
FwSizeType drained = 0; drained < this->m_fileInQueueDepth; drained++) {
97 FileInRequest request;
101 this->m_fileInQueue.
receive(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(
sizeof(request)),
102 Os::Queue::BlockingType::NONBLOCKING, actualSize, priority);
113 static_cast<FwAssertArgType>(valid.
e));
124 static_cast<FwAssertArgType>(valid.
e));
128 static_cast<FwAssertArgType>(valid.
e));
132 static_cast<FwAssertArgType>(valid.
e));
136 static_cast<FwAssertArgType>(valid.
e));
140 this->m_engine->
txFile(request.sourceFileName, request.destFileName, cfdpClass, keep, channelId,
191 this->m_engine->
receivePdu(static_cast<U8>(portNum), pduBuffer);
208 if (offset > 0 || length > 0) {
218 FileInRequest request;
221 if (sourceFileName.
length() >= request.sourceFileName.getCapacity() ||
222 destFileName.
length() >= request.destFileName.getCapacity()) {
228 request.sourceFileName = sourceFileName;
229 request.destFileName = destFileName;
230 request.context =
static_cast<U32
>(portNum);
233 this->m_fileInQueue.
send(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(
sizeof(request)), 0,
234 Os::Queue::BlockingType::NONBLOCKING);
247 void CfdpManager ::pingIn_handler(
FwIndexType portNum, U32 key) {
273 if (buffer.
getSize() == size) {
308 bufferData[0] =
static_cast<U8>((descriptor >> 8) & 0xFF);
309 bufferData[1] =
static_cast<U8>(descriptor & 0xFF);
327 void CfdpManager ::SendFile_cmdHandler(
FwOpcodeType opCode,
331 const Class& cfdpClass,
339 rspStatus = this->checkCommandChannelIndex(channelId);
344 this->m_engine->
txFile(sourceFileName, destFileName, cfdpClass.
e, keep.
e, channelId, priority, destId)) {
353 void CfdpManager ::PlaybackDirectory_cmdHandler(
FwOpcodeType opCode,
357 const Class& cfdpClass,
366 rspStatus = this->checkCommandChannelIndex(channelId);
370 cfdpClass.e, keep.e, channelId, priority, destId)) {
381 void CfdpManager ::PollDirectory_cmdHandler(
FwOpcodeType opCode,
386 const Class& cfdpClass,
395 rspStatus = this->checkCommandChannelIndex(channelId);
397 rspStatus = this->checkCommandChannelPollIndex(pollId);
402 cfdpClass.e, priority, destId, interval)) {
413 void CfdpManager ::StopPollDirectory_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId,
U8 pollId) {
418 rspStatus = this->checkCommandChannelIndex(channelId);
420 rspStatus = this->checkCommandChannelPollIndex(pollId);
433 void CfdpManager ::SetChannelFlow_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId,
const Flow& flowState) {
438 rspStatus = checkCommandChannelIndex(channelId);
447 void CfdpManager ::SuspendResumeTransaction_cmdHandler(
FwOpcodeType opCode,
452 const SuspendResume& action) {
457 rspStatus = checkCommandChannelIndex(channelId);
476 void CfdpManager ::CancelTransaction_cmdHandler(
FwOpcodeType opCode,
485 rspStatus = checkCommandChannelIndex(channelId);
500 void CfdpManager ::AbandonTransaction_cmdHandler(
FwOpcodeType opCode,
509 rspStatus = checkCommandChannelIndex(channelId);
524 void CfdpManager ::ResetCounters_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId) {
526 if (channelId == 0xFF) {
528 this->m_channelTelemetry[i] = Cfdp::ChannelTelemetry();
534 this->m_channelTelemetry[channelId] = Cfdp::ChannelTelemetry();
581 static_cast<FwAssertArgType>(valid.
e));
592 static_cast<FwAssertArgType>(valid.
e));
602 static_cast<FwAssertArgType>(valid.
e));
613 static_cast<FwAssertArgType>(valid.
e));
627 static_cast<FwAssertArgType>(valid.
e));
630 return paramArray[channelIndex].get_tmp_dir();
642 static_cast<FwAssertArgType>(valid.
e));
645 return paramArray[channelIndex].get_fail_dir();
657 static_cast<FwAssertArgType>(valid.
e));
660 return paramArray[channelIndex].get_ack_limit();
672 static_cast<FwAssertArgType>(valid.
e));
675 return paramArray[channelIndex].get_nack_limit();
687 static_cast<FwAssertArgType>(valid.
e));
690 return paramArray[channelIndex].get_ack_timer();
702 static_cast<FwAssertArgType>(valid.
e));
705 return paramArray[channelIndex].get_inactivity_timer();
717 static_cast<FwAssertArgType>(valid.
e));
720 return paramArray[channelIndex].get_dequeue_enabled();
732 static_cast<FwAssertArgType>(valid.
e));
735 return paramArray[channelIndex].get_move_dir();
747 static_cast<FwAssertArgType>(valid.
e));
750 return paramArray[channelIndex].get_max_outgoing_pdus_per_cycle();
void configure(Fw::MemAllocator &allocator, FwSizeType fileQueueDepth, FwEnumStoreType memId=0)
U32 paramGet_OutgoingFileChunkSize(Fw::ParamValid &valid)
Serialization/Deserialization operation was successful.
Svc::Ccsds::Cfdp::Keep paramGet_FileInDefaultKeep(Fw::ParamValid &valid)
void log_ACTIVITY_LO_TransactionResumed(Svc::Ccsds::Cfdp::TransactionSeq transactionSeq, Svc::Ccsds::Cfdp::EntityId entityId) const
void sendFileComplete(Svc::SendFileStatus::T status)
Status create(FwEnumStoreType id, const Fw::ConstStringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage through delegate
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
U8 getChannelId() const
Get the channel ID.
Status::T txFile(const Fw::String &src, const Fw::String &dst, Class::T cfdp_class, Keep::T keep, U8 chan_num, U8 priority, EntityId dest_id, TransactionInitType initType=TransactionInitType::INIT_BY_COMMAND)
Begin transmit of a file.
Enum used to determine if a file should be kept or deleted after a CFDP transaction.
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))=0
Status::T stopPollDir(U8 chanId, U8 pollId)
Stop polling a directory.
FwIdType FwOpcodeType
The type of a command opcode.
Status::T cancelTransactionBySeq(U8 channelId, TransactionSeq transactionSeq, EntityId entityId)
Cancel a transaction with graceful close-out.
void set_status(Svc::SendFileStatus::T status)
Set member status.
PlatformSizeType FwSizeType
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
void init(Fw::MemAllocator &allocator, FwEnumStoreType memId)
Initialize the CFDP engine.
Status
status returned from the queue send function
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
enum T e
The raw enum value.
U32 getOutgoingCounter() const
Get the outgoing PDU counter for this cycle.
U32 EntityId
Entity id size.
void log_ACTIVITY_LO_TransactionSuspended(Svc::Ccsds::Cfdp::TransactionSeq transactionSeq, Svc::Ccsds::Cfdp::EntityId entityId) const
void dataInReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port dataInReturn.
Auto-generated base for CfdpManager component.
void log_ACTIVITY_LO_PollDirInitiated(const Fw::StringBase &sourceDirectory) const
Log event PollDirInitiated.
U8 getNackLimitParam(U8 channelIndex)
enum T e
The raw enum value.
FwEnumStoreType getInstance() const
void fileDoneOut_out(FwIndexType portNum, const Svc::SendFileResponse &resp) const
Invoke output port fileDoneOut.
void tlmWrite_ChannelTelemetry(const Svc::Ccsds::Cfdp::ChannelTelemetryArray &arg, Fw::Time _tlmTime=Fw::Time()) const
U32 paramGet_RxCrcCalcBytesPerCycle(Fw::ParamValid &valid)
Fw::String getFailDirParam(U8 channelIndex)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
~CfdpManager()
Destroy CfdpManager object.
void log_ACTIVITY_HI_TransactionAbandoned(Svc::Ccsds::Cfdp::TransactionSeq transactionSeq, Svc::Ccsds::Cfdp::EntityId entityId) const
void log_ACTIVITY_HI_ResetCounters(U8 channelId) const
Log event ResetCounters.
void sendPduBuffer(Channel &channel, Fw::Buffer &pduBuffer)
void deinit() override
Tear down the fileIn request queue.
Status::T startPollDir(U8 chanId, U8 pollId, const Fw::String &srcDir, const Fw::String &dstDir, Class::T cfdp_class, U8 priority, EntityId destEid, U32 intervalSec)
Start polling a directory.
CfdpManager(const char *const compName)
Construct CfdpManager object.
SerializeStatus
forward declaration for string
void log_WARNING_LO_SendFileInitiateFail(const Fw::StringBase &sourceFileName) const
Log event SendFileInitiateFail.
ExternalSerializeBufferWithMemberCopy getDeserializer()
U32 TransactionSeq
transaction sequence number size
void returnPduBuffer(Channel &channel, Fw::Buffer &pduBuffer)
Fw::Enabled getDequeueEnabledParam(U8 channelIndex)
void log_ACTIVITY_LO_PlaybackInitiated(const Fw::StringBase &sourceDirectory) const
Log event PlaybackInitiated.
U8 getAckLimitParam(U8 channelIndex)
Svc::Ccsds::Cfdp::Class paramGet_FileInDefaultClass(Fw::ParamValid &valid)
virtual ~Engine()
Destroy the Engine object.
void setChannelFlowState(U8 channelId, Flow::T flowState)
Set channel flow state.
Status::T getPduBuffer(Fw::Buffer &buffer, Channel &channel, FwSizeType size)
Svc::Ccsds::Cfdp::EntityId paramGet_LocalEid(Fw::ParamValid &valid)
void log_WARNING_LO_InvalidChannelPoll(U8 pollId, U8 maxPollId) const
Log event InvalidChannelPoll.
void receivePdu(U8 chan_id, const Fw::Buffer &buffer)
Receive and process a PDU.
void log_ACTIVITY_HI_TransactionCanceled(Svc::Ccsds::Cfdp::TransactionSeq transactionSeq, Svc::Ccsds::Cfdp::EntityId entityId) const
void log_WARNING_LO_InvalidChannel(U8 channelId, U8 maxChannelId) const
Log event InvalidChannel.
void deinit() override
Allows de-initialization on teardown.
void log_WARNING_LO_TransactionNotFound(Svc::Ccsds::Cfdp::TransactionSeq transactionSeq, Svc::Ccsds::Cfdp::EntityId entityId) const
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
void log_WARNING_LO_UnsupportedSendFileArguments(U32 offset, U32 length) const
Log event UnsupportedSendFileArguments.
Generic CFDP error return code.
void teardown() override
teardown the queue
const char * toChar() const
Convert to a C-style char*.
U32 getRxCrcCalcBytesPerCycleParam(void)
enum T e
The raw enum value.
Enabled and disabled states.
Command successfully executed.
uint8_t U8
8-bit unsigned integer
void dataOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port dataOut.
CFDP operation has been successful.
EntityId getLocalEidParam(void)
void bufferDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port bufferDeallocate.
U8 paramGet_FileInDefaultPriority(Fw::ParamValid &valid)
FwSizeType getSize() const
U32 getAckTimerParam(U8 channelIndex)
void log_ACTIVITY_LO_SetFlowState(U8 channelId, const Svc::Ccsds::Cfdp::Flow &flowState) const
Log event SetFlowState.
Fw::Buffer bufferAllocate_out(FwIndexType portNum, FwSizeType size) const
Invoke output port bufferAllocate.
U32 getInactivityTimerParam(U8 channelIndex)
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
Command had execution error.
Structure for telemetry counters for a single CFDP channel.
void cycle()
Cycle the engine once per scheduler call.
Memory Allocation base class.
void log_WARNING_LO_BuffersExhausted() const
Log event BuffersExhausted.
PlatformIndexType FwIndexType
U32 getOutgoingFileChunkSizeParam(void)
Transaction initiated via port interface.
Send file response struct.
void set_context(U32 context)
Set member context.
void incrementOutgoingCounter()
Increment the outgoing PDU counter.
Structure for the telemetry array of CFDP channels.
Command failed validation.
RateGroupDivider component implementation.
virtual SizeType length() const
Get the length of the string.
message sent/received okay
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
Svc::Ccsds::Cfdp::EntityId paramGet_FileInDefaultDestEntityId(Fw::ParamValid &valid)
Enum representing parameter validity.
Status::T setSuspendResumeTransaction(U8 channelId, TransactionSeq transactionSeq, EntityId entityId, SuspendResume::T action)
Set transaction suspend state.
U32 getMaxOutgoingPdusPerCycleParam(U8 channelIndex)
Fw::String getTmpDirParam(U8 channelIndex)
void cleanup()
Cleanup CFDP engine and deallocate resources.
Fw::String getMoveDirParam(U8 channelIndex)
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Svc::Ccsds::Cfdp::ChannelArrayParams paramGet_ChannelConfig(Fw::ParamValid &valid)
Status::T abandonTransaction(U8 channelId, TransactionSeq transactionSeq, EntityId entityId)
Abandon a transaction immediately.
U8 getPostInactivitySendRetriesParam(void)
Send PDU: No send buffer available, throttling limit reached.
U8 paramGet_PostInactivitySendRetries(Fw::ParamValid &valid)
Status::T playbackDir(const Fw::String &src, const Fw::String &dst, Class::T cfdp_class, Keep::T keep, U8 chan, U8 priority, EntityId dest_id)
Begin transmit of a directory.
U8 paramGet_FileInDefaultChannel(Fw::ParamValid &valid)
void log_ACTIVITY_LO_PollDirStopped(U8 channelId, U8 pollId) const
Log event PollDirStopped.