30 if (this->m_engine !=
nullptr) {
38 this->m_engine =
static_cast<Engine*
>(allocator.
allocate(memId, engineSize));
40 (void)
new (this->m_engine)
Engine(
this);
41 this->m_engine->
init(allocator, memId);
44 this->m_allocator = &allocator;
45 this->m_allocatorId = memId;
53 this->m_fileInQueueDepth = fileQueueDepth;
56 static_cast<FwSizeType>(
sizeof(FileInRequest)));
67 if ((this->m_allocator !=
nullptr) && (this->m_engine !=
nullptr)) {
71 this->m_allocator->
deallocate(this->m_allocatorId, this->m_engine);
72 this->m_engine =
nullptr;
80 void CfdpManager ::run1Hz_handler(
FwIndexType portNum, U32 context) {
85 this->drainFileInQueue();
87 this->m_engine->
cycle();
93 void CfdpManager ::drainFileInQueue() {
97 for (
FwSizeType drained = 0; drained < this->m_fileInQueueDepth; drained++) {
98 FileInRequest request;
102 this->m_fileInQueue.
receive(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(
sizeof(request)),
103 Os::Queue::BlockingType::NONBLOCKING, actualSize, priority);
136 this->m_engine->
txFile(request.sourceFileName, request.destFileName, cfdpClass, keep, channelId,
187 this->m_engine->
receivePdu(static_cast<U8>(portNum), pduBuffer);
204 if (offset > 0 || length > 0) {
214 FileInRequest request;
217 if (sourceFileName.
length() >= request.sourceFileName.getCapacity() ||
218 destFileName.
length() >= request.destFileName.getCapacity()) {
224 request.sourceFileName = sourceFileName;
225 request.destFileName = destFileName;
226 request.context =
static_cast<U32
>(portNum);
229 this->m_fileInQueue.
send(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(
sizeof(request)), 0,
230 Os::Queue::BlockingType::NONBLOCKING);
243 void CfdpManager ::pingIn_handler(
FwIndexType portNum, U32 key) {
269 if (buffer.
getSize() == size) {
304 bufferData[0] =
static_cast<U8>((descriptor >> 8) & 0xFF);
305 bufferData[1] =
static_cast<U8>(descriptor & 0xFF);
323 void CfdpManager ::SendFile_cmdHandler(
FwOpcodeType opCode,
327 const Class& cfdpClass,
335 rspStatus = this->checkCommandChannelIndex(channelId);
340 this->m_engine->
txFile(sourceFileName, destFileName, cfdpClass.
e, keep.
e, channelId, priority, destId)) {
349 void CfdpManager ::PlaybackDirectory_cmdHandler(
FwOpcodeType opCode,
353 const Class& cfdpClass,
362 rspStatus = this->checkCommandChannelIndex(channelId);
366 cfdpClass.e, keep.e, channelId, priority, destId)) {
377 void CfdpManager ::PollDirectory_cmdHandler(
FwOpcodeType opCode,
382 const Class& cfdpClass,
391 rspStatus = this->checkCommandChannelIndex(channelId);
393 rspStatus = this->checkCommandChannelPollIndex(pollId);
396 rspStatus = this->checkCommandPollInterval(interval);
401 cfdpClass.e, priority, destId, interval)) {
412 void CfdpManager ::StopPollDirectory_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId,
U8 pollId) {
417 rspStatus = this->checkCommandChannelIndex(channelId);
419 rspStatus = this->checkCommandChannelPollIndex(pollId);
432 void CfdpManager ::SetChannelFlow_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId,
const Flow& flowState) {
437 rspStatus = checkCommandChannelIndex(channelId);
446 void CfdpManager ::SuspendResumeTransaction_cmdHandler(
FwOpcodeType opCode,
451 const SuspendResume& action) {
456 rspStatus = checkCommandChannelIndex(channelId);
475 void CfdpManager ::CancelTransaction_cmdHandler(
FwOpcodeType opCode,
484 rspStatus = checkCommandChannelIndex(channelId);
499 void CfdpManager ::AbandonTransaction_cmdHandler(
FwOpcodeType opCode,
508 rspStatus = checkCommandChannelIndex(channelId);
523 void CfdpManager ::ResetCounters_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq,
U8 channelId) {
525 if (channelId == 0xFF) {
527 this->m_channelTelemetry[i] = Cfdp::ChannelTelemetry();
533 this->m_channelTelemetry[channelId] = Cfdp::ChannelTelemetry();
635 return paramArray[channelIndex].get_tmp_dir();
649 return paramArray[channelIndex].get_fail_dir();
663 return paramArray[channelIndex].get_ack_limit();
677 return paramArray[channelIndex].get_nack_limit();
691 return paramArray[channelIndex].get_ack_timer();
705 return paramArray[channelIndex].get_inactivity_timer();
719 return paramArray[channelIndex].get_dequeue_enabled();
733 return paramArray[channelIndex].get_move_dir();
747 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.
#define FW_PARAM_OK(paramValid)
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.
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
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
void log_ACTIVITY_LO_PollDirInitiated(const Fw::StringBase &sourceDirectory, U8 pollId) const
Log event PollDirInitiated.
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.
void log_WARNING_LO_InvalidPollInterval(U32 interval) const
Log event InvalidPollInterval.
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
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.