F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
CfdpManager.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title CfdpManager.cpp
3 // \author Brian Campuzano
4 // \brief cpp file for CfdpManager component implementation class
5 // ======================================================================
6 
7 #include <Fw/Com/ComPacket.hpp>
8 #include <Os/QueueString.hpp>
12 #include <new>
13 
14 namespace Svc {
15 namespace Ccsds {
16 namespace Cfdp {
17 
18 // ----------------------------------------------------------------------
19 // Component construction and destruction
20 // ----------------------------------------------------------------------
21 
22 CfdpManager ::CfdpManager(const char* const compName) : CfdpManagerComponentBase(compName), m_engine(nullptr) {}
23 
25  // Clean up the queue resources allocated during initialization
26  this->deinit();
27 
28  // If cleanup() was not called, clean up manually
29  if (this->m_engine != nullptr) {
30  this->cleanup();
31  }
32 }
33 
34 void CfdpManager ::configure(Fw::MemAllocator& allocator, FwSizeType fileQueueDepth, FwEnumStoreType memId) {
35  // Allocate and initialize the CFDP engine
36  FwSizeType engineSize = sizeof(Engine);
37  this->m_engine = static_cast<Engine*>(allocator.allocate(memId, engineSize));
38  FW_ASSERT(this->m_engine != nullptr);
39  (void)new (this->m_engine) Engine(this);
40  this->m_engine->init(allocator, memId);
41 
42  // Store allocator for cleanup
43  this->m_allocator = &allocator;
44  this->m_allocatorId = memId;
45 
46  // Initialize telemetry counters to zero
47  for (U8 i = 0; i < Cfdp::NumChannels; i++) {
48  this->m_channelTelemetry[i] = Cfdp::ChannelTelemetry();
49  }
50 
51  // Create the fileIn request handoff queue
52  this->m_fileInQueueDepth = fileQueueDepth;
53  Os::Queue::Status queueStat =
54  this->m_fileInQueue.create(this->getInstance(), Os::QueueString("cfdpFileInQueue"), fileQueueDepth,
55  static_cast<FwSizeType>(sizeof(FileInRequest)));
56  FW_ASSERT(queueStat == Os::Queue::OP_OK, static_cast<FwAssertArgType>(queueStat));
57 }
58 
60  this->m_fileInQueue.teardown();
62 }
63 
65  // Only try to deallocate if both pointers are non-null
66  if ((this->m_allocator != nullptr) && (this->m_engine != nullptr)) {
67  // Manually call destructor since we used placement new
68  this->m_engine->~Engine();
69  // Deallocate the memory
70  this->m_allocator->deallocate(this->m_allocatorId, this->m_engine);
71  this->m_engine = nullptr;
72  }
73 }
74 
75 // ----------------------------------------------------------------------
76 // Handler implementations for typed input ports
77 // ----------------------------------------------------------------------
78 
79 void CfdpManager ::run1Hz_handler(FwIndexType portNum, U32 context) {
80  // The timer logic built into the CFDP engine requires it to be driven at 1 Hz
81  FW_ASSERT(this->m_engine != nullptr);
82 
83  // Drain any port-initiated file send requests before cycling the engine
84  this->drainFileInQueue();
85 
86  this->m_engine->cycle();
87 
88  // Emit telemetry once per second
89  this->tlmWrite_ChannelTelemetry(this->m_channelTelemetry);
90 }
91 
92 void CfdpManager ::drainFileInQueue() {
93  FW_ASSERT(this->m_engine != nullptr);
94 
95  // Drain the whole queue; the depth bound guarantees the loop terminates.
96  for (FwSizeType drained = 0; drained < this->m_fileInQueueDepth; drained++) {
97  FileInRequest request;
98  FwSizeType actualSize = 0;
99  FwQueuePriorityType priority = 0;
100  Os::Queue::Status status =
101  this->m_fileInQueue.receive(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(sizeof(request)),
102  Os::Queue::BlockingType::NONBLOCKING, actualSize, priority);
103 
104  // Queue empty (or any non-OK status) ends the drain for this cycle
105  if (status != Os::Queue::Status::OP_OK || actualSize != sizeof(request)) {
106  break;
107  }
108 
109  // Look up the per-channel default parameters
110  Fw::ParamValid valid;
111  U8 channelId = this->paramGet_FileInDefaultChannel(valid);
113  static_cast<FwAssertArgType>(valid.e));
114 
115  // Reject an out-of-range channel parameter rather than letting it assert in Engine::txFile
116  if (channelId >= Cfdp::NumChannels) {
119  continue;
120  }
121 
122  EntityId destEid = this->paramGet_FileInDefaultDestEntityId(valid);
124  static_cast<FwAssertArgType>(valid.e));
125 
126  Class::T cfdpClass = this->paramGet_FileInDefaultClass(valid);
128  static_cast<FwAssertArgType>(valid.e));
129 
130  Keep::T keep = this->paramGet_FileInDefaultKeep(valid);
132  static_cast<FwAssertArgType>(valid.e));
133 
134  U8 priorityParam = this->paramGet_FileInDefaultPriority(valid);
136  static_cast<FwAssertArgType>(valid.e));
137 
138  // Initiate the transfer on the active thread
139  Status::T txStatus =
140  this->m_engine->txFile(request.sourceFileName, request.destFileName, cfdpClass, keep, channelId,
141  priorityParam, destEid, TransactionInitType::INIT_BY_PORT);
142 
143  // The caller already received queue-acceptance success; report the deferred initiation
144  // result via fileDoneOut so a failed initiation does not leave the caller waiting forever.
145  if (txStatus != Status::SUCCESS) {
146  this->log_WARNING_LO_SendFileInitiateFail(request.sourceFileName);
148  }
149  }
150 }
151 
152 void CfdpManager ::dataReturnIn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) {
153  // dataReturnIn is the allocated buffer coming back from the dataOut call
154  // Port mapping is the same from bufferAllocate -> dataOut -> dataReturnIn -> bufferDeallocate
155  FW_ASSERT(portNum < Cfdp::NumChannels, portNum, Cfdp::NumChannels);
156  this->bufferDeallocate_out(portNum, fwBuffer);
157 }
158 
159 void CfdpManager ::dataIn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) {
160  // There is a direct mapping between port number and channel index
161  FW_ASSERT(portNum < Cfdp::NumChannels, portNum, Cfdp::NumChannels);
162  FW_ASSERT(portNum >= 0, portNum);
163 
164  // Strip FW_PACKET_FILE descriptor (first 2 bytes) from buffer
165  // FprimeRouter sends the entire Space Packet data field, which includes the packet type descriptor
166  if (fwBuffer.getSize() < sizeof(FwPacketDescriptorType)) {
167  // Buffer too small - silently ignore
168  this->dataInReturn_out(portNum, fwBuffer);
169  return;
170  }
171 
172  // Read and verify packet type descriptor
173  FwPacketDescriptorType packetType = 0;
174  Fw::SerializeStatus status = fwBuffer.getDeserializer().deserializeTo(packetType);
175  if (status != Fw::FW_SERIALIZE_OK || packetType != Fw::ComPacketType::FW_PACKET_FILE) {
176  // Invalid packet type - silently ignore (consistent with FileUplink behavior)
177  this->dataInReturn_out(portNum, fwBuffer);
178  return;
179  }
180 
181  // Create a new buffer view that skips the descriptor
182  // The deserializer advanced past the 2-byte descriptor, but Engine::receivePdu
183  // calls getData() which returns the raw pointer from byte 0. We need to create
184  // a buffer that starts after the descriptor.
185  const FwSizeType descriptorSize = sizeof(FwPacketDescriptorType);
186  Fw::Buffer pduBuffer(fwBuffer.getData() + descriptorSize, fwBuffer.getSize() - descriptorSize,
187  fwBuffer.getContext());
188 
189  // Pass the adjusted buffer to the engine
190  FW_ASSERT(this->m_engine != nullptr);
191  this->m_engine->receivePdu(static_cast<U8>(portNum), pduBuffer);
192 
193  // Return buffer
194  this->dataInReturn_out(portNum, fwBuffer);
195 }
196 
197 Svc::SendFileResponse CfdpManager ::fileIn_handler(FwIndexType portNum,
198  const Fw::StringBase& sourceFileName,
199  const Fw::StringBase& destFileName,
200  U32 offset,
201  U32 length) {
202  Svc::SendFileResponse response;
203  // Set context to portNum so we can identify this transaction later
204  response.set_context(static_cast<U32>(portNum));
205 
206  // CFDP engine does not support partial file retransmit at this time
207  // Offset and length must be 0 to send the entire file
208  if (offset > 0 || length > 0) {
210  this->log_WARNING_LO_UnsupportedSendFileArguments(offset, length);
211  return response;
212  }
213 
214  // Copy the request into the internal queue instead of touching the engine here. This handler
215  // runs on the caller's thread (guarded port); the engine is mutated on the active thread when
216  // run1Hz drains the queue. The synchronous response only indicates that the request was
217  // accepted for processing; the final transfer result is delivered later via fileDoneOut.
218  FileInRequest request;
219 
220  // Guard against filenames that would not fit in the queued request
221  if (sourceFileName.length() >= request.sourceFileName.getCapacity() ||
222  destFileName.length() >= request.destFileName.getCapacity()) {
224  this->log_WARNING_LO_SendFileInitiateFail(sourceFileName);
225  return response;
226  }
227 
228  request.sourceFileName = sourceFileName;
229  request.destFileName = destFileName;
230  request.context = static_cast<U32>(portNum);
231 
232  Os::Queue::Status status =
233  this->m_fileInQueue.send(reinterpret_cast<U8*>(&request), static_cast<FwSizeType>(sizeof(request)), 0,
234  Os::Queue::BlockingType::NONBLOCKING);
235 
236  if (status != Os::Queue::Status::OP_OK) {
237  // Queue full - reject the request so the caller can retry later
239  this->log_WARNING_LO_SendFileInitiateFail(sourceFileName);
240  } else {
242  }
243 
244  return response;
245 }
246 
247 void CfdpManager ::pingIn_handler(FwIndexType portNum, U32 key) {
248  // send ping response
249  this->pingOut_out(0, key);
250 }
251 
252 // ----------------------------------------------------------------------
253 // Port calls that are invoked by the CFDP engine
254 // These functions are analogous to the functions in cf_cfdp_sbintf.*
255 // However these functions were not directly migrated due to the
256 // architectural differences between F' and cFE
257 // ----------------------------------------------------------------------
258 
260  Status::T status = Status::ERROR;
261  FwIndexType portNum;
262 
263  // There is a direct mapping between channel index and port number
264  portNum = static_cast<FwIndexType>(channel.getChannelId());
265 
266  // Check if we have reached the maximum number of output PDUs for this cycle
267  U32 max_pdus = getMaxOutgoingPdusPerCycleParam(channel.getChannelId());
268  if (channel.getOutgoingCounter() >= max_pdus) {
270  } else {
271  buffer = this->bufferAllocate_out(portNum, size);
272  // Check the allocation was successful based on size
273  if (buffer.getSize() == size) {
274  channel.incrementOutgoingCounter();
275  status = Status::SUCCESS;
276  } else {
279  }
280  }
281  return status;
282 }
283 
285  FwIndexType portNum;
286 
287  // There is a direct mapping between channel index and port number
288  portNum = static_cast<FwIndexType>(channel.getChannelId());
289 
290  // Was unable to successfully populate the PDU buffer, return it
291  this->bufferDeallocate_out(portNum, pduBuffer);
292 }
293 
294 void CfdpManager ::sendPduBuffer(Channel& channel, Fw::Buffer& pduBuffer) {
295  FwIndexType portNum;
296 
297  // There is a direct mapping between channel index and port number
298  portNum = static_cast<FwIndexType>(channel.getChannelId());
299 
300  // ComQueue expects buffers to start with a 2-byte packet descriptor (APID)
301  // The PDU data has already been serialized at offset PACKET_DESCRIPTOR_SIZE,
302  // so we just need to write the descriptor at the beginning
303 
304  U8* bufferData = pduBuffer.getData();
305 
306  // Write FW_PACKET_FILE descriptor at the beginning (big-endian U16)
307  const FwPacketDescriptorType descriptor = static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_FILE);
308  bufferData[0] = static_cast<U8>((descriptor >> 8) & 0xFF); // High byte
309  bufferData[1] = static_cast<U8>(descriptor & 0xFF); // Low byte
310 
311  // Send buffer with descriptor
312  this->dataOut_out(portNum, pduBuffer);
313 }
314 
316  Svc::SendFileResponse response;
317  response.set_status(status);
318  response.set_context(0);
319 
320  this->fileDoneOut_out(0, response);
321 }
322 
323 // ----------------------------------------------------------------------
324 // Handler implementations for commands
325 // ----------------------------------------------------------------------
326 
327 void CfdpManager ::SendFile_cmdHandler(FwOpcodeType opCode,
328  U32 cmdSeq,
329  U8 channelId,
330  EntityId destId,
331  const Class& cfdpClass,
332  const Keep& keep,
333  U8 priority,
334  const Fw::CmdStringArg& sourceFileName,
335  const Fw::CmdStringArg& destFileName) {
337 
338  // Check channel index is in range
339  rspStatus = this->checkCommandChannelIndex(channelId);
340  FW_ASSERT(this->m_engine != nullptr);
341 
342  if (rspStatus == Fw::CmdResponse::OK) {
343  if (Status::SUCCESS !=
344  this->m_engine->txFile(sourceFileName, destFileName, cfdpClass.e, keep.e, channelId, priority, destId)) {
345  // Engine emits specific failure reason EVR (e.g., MaxTxTransactionsReached)
347  }
348  }
349 
350  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
351 }
352 
353 void CfdpManager ::PlaybackDirectory_cmdHandler(FwOpcodeType opCode,
354  U32 cmdSeq,
355  U8 channelId,
356  EntityId destId,
357  const Class& cfdpClass,
358  const Keep& keep,
359  U8 priority,
360  const Fw::CmdStringArg& sourceDirectory,
361  const Fw::CmdStringArg& destDirectory) {
363 
364  FW_ASSERT(this->m_engine != nullptr);
365  // Check channel index is in range
366  rspStatus = this->checkCommandChannelIndex(channelId);
367 
368  if (rspStatus == Fw::CmdResponse::OK) {
369  if (Status::SUCCESS == this->m_engine->playbackDir(sourceDirectory.toChar(), destDirectory.toChar(),
370  cfdpClass.e, keep.e, channelId, priority, destId)) {
371  this->log_ACTIVITY_LO_PlaybackInitiated(sourceDirectory);
372  } else {
373  // Engine emits specific failure reason EVR (e.g., PlaybackDirOpenFailed, PlaybackDirSlotUnavailable)
375  }
376  }
377 
378  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
379 }
380 
381 void CfdpManager ::PollDirectory_cmdHandler(FwOpcodeType opCode,
382  U32 cmdSeq,
383  U8 channelId,
384  U8 pollId,
385  EntityId destId,
386  const Class& cfdpClass,
387  U8 priority,
388  U32 interval,
389  const Fw::CmdStringArg& sourceDirectory,
390  const Fw::CmdStringArg& destDirectory) {
392 
393  FW_ASSERT(this->m_engine != nullptr);
394  // Check channel index and poll index are in range
395  rspStatus = this->checkCommandChannelIndex(channelId);
396  if (rspStatus == Fw::CmdResponse::OK) {
397  rspStatus = this->checkCommandChannelPollIndex(pollId);
398  }
399 
400  if (rspStatus == Fw::CmdResponse::OK) {
401  if (Status::SUCCESS == this->m_engine->startPollDir(channelId, pollId, sourceDirectory, destDirectory,
402  cfdpClass.e, priority, destId, interval)) {
403  this->log_ACTIVITY_LO_PollDirInitiated(sourceDirectory);
404  } else {
405  // Failure EVR was already emitted
407  }
408  }
409 
410  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
411 }
412 
413 void CfdpManager ::StopPollDirectory_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U8 channelId, U8 pollId) {
415 
416  FW_ASSERT(this->m_engine != nullptr);
417  // Check channel index and poll index are in range
418  rspStatus = this->checkCommandChannelIndex(channelId);
419  if (rspStatus == Fw::CmdResponse::OK) {
420  rspStatus = this->checkCommandChannelPollIndex(pollId);
421  }
422 
423  if ((rspStatus == Fw::CmdResponse::OK) && (Status::SUCCESS == this->m_engine->stopPollDir(channelId, pollId))) {
424  this->log_ACTIVITY_LO_PollDirStopped(channelId, pollId);
425  }
426  // Failure EVR was already emitted
427  // Not failing the command if the stop request failed
428  // This allows operators to reinforce state prior to calling PollDirectory
429 
430  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
431 }
432 
433 void CfdpManager ::SetChannelFlow_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U8 channelId, const Flow& flowState) {
435 
436  FW_ASSERT(this->m_engine != nullptr);
437  // Check channel index is in range
438  rspStatus = checkCommandChannelIndex(channelId);
439  if (rspStatus == Fw::CmdResponse::OK) {
440  this->m_engine->setChannelFlowState(channelId, flowState);
441  this->log_ACTIVITY_LO_SetFlowState(channelId, flowState);
442  }
443 
444  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
445 }
446 
447 void CfdpManager ::SuspendResumeTransaction_cmdHandler(FwOpcodeType opCode,
448  U32 cmdSeq,
449  U8 channelId,
450  TransactionSeq transactionSeq,
451  EntityId entityId,
452  const SuspendResume& action) {
454 
455  FW_ASSERT(this->m_engine != nullptr);
456 
457  rspStatus = checkCommandChannelIndex(channelId);
458 
459  if (rspStatus == Fw::CmdResponse::OK) {
460  Status::T status = this->m_engine->setSuspendResumeTransaction(channelId, transactionSeq, entityId, action);
461  if (status == Status::SUCCESS) {
462  if (action == SuspendResume::SUSPEND) {
463  log_ACTIVITY_LO_TransactionSuspended(transactionSeq, entityId);
464  } else {
465  log_ACTIVITY_LO_TransactionResumed(transactionSeq, entityId);
466  }
467  } else {
468  log_WARNING_LO_TransactionNotFound(transactionSeq, entityId);
470  }
471  }
472 
473  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
474 }
475 
476 void CfdpManager ::CancelTransaction_cmdHandler(FwOpcodeType opCode,
477  U32 cmdSeq,
478  U8 channelId,
479  TransactionSeq transactionSeq,
480  EntityId entityId) {
482 
483  FW_ASSERT(this->m_engine != nullptr);
484 
485  rspStatus = checkCommandChannelIndex(channelId);
486 
487  if (rspStatus == Fw::CmdResponse::OK) {
488  Status::T status = this->m_engine->cancelTransactionBySeq(channelId, transactionSeq, entityId);
489  if (status == Status::SUCCESS) {
490  log_ACTIVITY_HI_TransactionCanceled(transactionSeq, entityId);
491  } else {
492  log_WARNING_LO_TransactionNotFound(transactionSeq, entityId);
494  }
495  }
496 
497  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
498 }
499 
500 void CfdpManager ::AbandonTransaction_cmdHandler(FwOpcodeType opCode,
501  U32 cmdSeq,
502  U8 channelId,
503  TransactionSeq transactionSeq,
504  EntityId entityId) {
506 
507  FW_ASSERT(this->m_engine != nullptr);
508 
509  rspStatus = checkCommandChannelIndex(channelId);
510 
511  if (rspStatus == Fw::CmdResponse::OK) {
512  Status::T status = this->m_engine->abandonTransaction(channelId, transactionSeq, entityId);
513  if (status == Status::SUCCESS) {
514  log_ACTIVITY_HI_TransactionAbandoned(transactionSeq, entityId);
515  } else {
516  log_WARNING_LO_TransactionNotFound(transactionSeq, entityId);
518  }
519  }
520 
521  this->cmdResponse_out(opCode, cmdSeq, rspStatus);
522 }
523 
524 void CfdpManager ::ResetCounters_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U8 channelId) {
525  // 0xFF means reset all channels
526  if (channelId == 0xFF) {
527  for (U8 i = 0; i < Cfdp::NumChannels; i++) {
528  this->m_channelTelemetry[i] = Cfdp::ChannelTelemetry();
529  }
530  this->log_ACTIVITY_HI_ResetCounters(0xFF);
531  }
532  // Otherwise reset specific channel
533  else if (channelId < Cfdp::NumChannels) {
534  this->m_channelTelemetry[channelId] = Cfdp::ChannelTelemetry();
535  this->log_ACTIVITY_HI_ResetCounters(channelId);
536  } else {
537  // Invalid channel ID
538  this->log_WARNING_LO_InvalidChannel(channelId, Cfdp::NumChannels - 1);
539  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR);
540  return;
541  }
542 
543  // Emit updated telemetry
544  this->tlmWrite_ChannelTelemetry(this->m_channelTelemetry);
545 
546  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
547 }
548 
549 // ----------------------------------------------------------------------
550 // Private command helper functions
551 // ----------------------------------------------------------------------
552 
553 Fw::CmdResponse::T CfdpManager ::checkCommandChannelIndex(U8 channelIndex) {
554  if (channelIndex >= Cfdp::NumChannels) {
557  } else {
558  return Fw::CmdResponse::OK;
559  }
560 }
561 
562 Fw::CmdResponse::T CfdpManager ::checkCommandChannelPollIndex(U8 pollIndex) {
563  if (pollIndex >= MaxPollingDirPerChan) {
566  } else {
567  return Fw::CmdResponse::OK;
568  }
569 }
570 
571 // ----------------------------------------------------------------------
572 // Parameter helpers used by the CFDP engine
573 // ----------------------------------------------------------------------
574 
576  Fw::ParamValid valid;
577 
578  // Check for coding errors as all CFDP parameters must have a default
579  EntityId localEid = this->paramGet_LocalEid(valid);
581  static_cast<FwAssertArgType>(valid.e));
582 
583  return localEid;
584 }
585 
587  Fw::ParamValid valid;
588 
589  // Check for coding errors as all CFDP parameters must have a default
590  U32 chunkSize = this->paramGet_OutgoingFileChunkSize(valid);
592  static_cast<FwAssertArgType>(valid.e));
593 
594  return chunkSize;
595 }
597  Fw::ParamValid valid;
598 
599  // Check for coding errors as all CFDP parameters must have a default
600  U32 rxSize = this->paramGet_RxCrcCalcBytesPerCycle(valid);
602  static_cast<FwAssertArgType>(valid.e));
603 
604  return rxSize;
605 }
606 
608  Fw::ParamValid valid;
609 
610  // Check for coding errors as all CFDP parameters must have a default
611  U8 retries = this->paramGet_PostInactivitySendRetries(valid);
613  static_cast<FwAssertArgType>(valid.e));
614 
615  return retries;
616 }
617 
619  Fw::ParamValid valid;
620 
621  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
622 
623  // Check for coding errors as all CFDP parameters must have a default
624  // Get the array first
625  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
627  static_cast<FwAssertArgType>(valid.e));
628 
629  // Now get individual parameter
630  return paramArray[channelIndex].get_tmp_dir();
631 }
632 
634  Fw::ParamValid valid;
635 
636  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
637 
638  // Check for coding errors as all CFDP parameters must have a default
639  // Get the array first
640  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
642  static_cast<FwAssertArgType>(valid.e));
643 
644  // Now get individual parameter
645  return paramArray[channelIndex].get_fail_dir();
646 }
647 
649  Fw::ParamValid valid;
650 
651  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
652 
653  // Check for coding errors as all CFDP parameters must have a default
654  // Get the array first
655  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
657  static_cast<FwAssertArgType>(valid.e));
658 
659  // Now get individual parameter
660  return paramArray[channelIndex].get_ack_limit();
661 }
662 
664  Fw::ParamValid valid;
665 
666  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
667 
668  // Check for coding errors as all CFDP parameters must have a default
669  // Get the array first
670  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
672  static_cast<FwAssertArgType>(valid.e));
673 
674  // Now get individual parameter
675  return paramArray[channelIndex].get_nack_limit();
676 }
677 
679  Fw::ParamValid valid;
680 
681  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
682 
683  // Check for coding errors as all CFDP parameters must have a default
684  // Get the array first
685  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
687  static_cast<FwAssertArgType>(valid.e));
688 
689  // Now get individual parameter
690  return paramArray[channelIndex].get_ack_timer();
691 }
692 
694  Fw::ParamValid valid;
695 
696  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
697 
698  // Check for coding errors as all CFDP parameters must have a default
699  // Get the array first
700  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
702  static_cast<FwAssertArgType>(valid.e));
703 
704  // Now get individual parameter
705  return paramArray[channelIndex].get_inactivity_timer();
706 }
707 
709  Fw::ParamValid valid;
710 
711  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
712 
713  // Check for coding errors as all CFDP parameters must have a default
714  // Get the array first
715  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
717  static_cast<FwAssertArgType>(valid.e));
718 
719  // Now get individual parameter
720  return paramArray[channelIndex].get_dequeue_enabled();
721 }
722 
724  Fw::ParamValid valid;
725 
726  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
727 
728  // Check for coding errors as all CFDP parameters must have a default
729  // Get the array first
730  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
732  static_cast<FwAssertArgType>(valid.e));
733 
734  // Now get individual parameter
735  return paramArray[channelIndex].get_move_dir();
736 }
737 
739  Fw::ParamValid valid;
740 
741  FW_ASSERT(channelIndex < Cfdp::NumChannels, channelIndex, Cfdp::NumChannels);
742 
743  // Check for coding errors as all CFDP parameters must have a default
744  // Get the array first
745  ChannelArrayParams paramArray = paramGet_ChannelConfig(valid);
747  static_cast<FwAssertArgType>(valid.e));
748 
749  // Now get individual parameter
750  return paramArray[channelIndex].get_max_outgoing_pdus_per_cycle();
751 }
752 
753 } // namespace Cfdp
754 } // namespace Ccsds
755 } // namespace Svc
void configure(Fw::MemAllocator &allocator, FwSizeType fileQueueDepth, FwEnumStoreType memId=0)
Definition: CfdpManager.cpp:34
Serialization/Deserialization operation was successful.
CFDP Protocol Engine.
Definition: Engine.hpp:89
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
Definition: Queue.cpp:22
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
U8 getChannelId() const
Get the channel ID.
Definition: Channel.hpp:178
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.
Definition: Engine.cpp:746
CFDP Channel class.
Definition: Channel.hpp:56
Enum used to determine if a file should be kept or deleted after a CFDP transaction.
Definition: KeepEnumAc.hpp:22
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.
Definition: Engine.cpp:921
FwIdType FwOpcodeType
The type of a command opcode.
Operation succeeded.
Definition: Os.hpp:27
Status::T cancelTransactionBySeq(U8 channelId, TransactionSeq transactionSeq, EntityId entityId)
Cancel a transaction with graceful close-out.
Definition: Engine.cpp:695
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
Definition: Queue.cpp:71
I32 FwEnumStoreType
void init(Fw::MemAllocator &allocator, FwEnumStoreType memId)
Initialize the CFDP engine.
Definition: Engine.cpp:88
Status
status returned from the queue send function
Definition: Queue.hpp:30
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.
Definition: Channel.hpp:185
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.
Definition: KeepEnumAc.hpp:207
U32 getContext() const
Definition: Buffer.cpp:64
FwEnumStoreType getInstance() const
void fileDoneOut_out(FwIndexType portNum, const Svc::SendFileResponse &resp) const
Invoke output port fileDoneOut.
U8 * getData() const
Definition: Buffer.cpp:56
void tlmWrite_ChannelTelemetry(const Svc::Ccsds::Cfdp::ChannelTelemetryArray &arg, Fw::Time _tlmTime=Fw::Time()) const
Fw::String getFailDirParam(U8 channelIndex)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
T
The raw enum type.
~CfdpManager()
Destroy CfdpManager object.
Definition: CfdpManager.cpp:24
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.
Definition: CfdpManager.cpp:59
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.
Definition: Engine.cpp:884
CfdpManager(const char *const compName)
Construct CfdpManager object.
Definition: CfdpManager.cpp:22
SerializeStatus
forward declaration for string
void log_WARNING_LO_SendFileInitiateFail(const Fw::StringBase &sourceFileName) const
Log event SendFileInitiateFail.
ExternalSerializeBufferWithMemberCopy getDeserializer()
Definition: Buffer.cpp:105
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)
T
The raw enum type.
Definition: KeepEnumAc.hpp:36
virtual ~Engine()
Destroy the Engine object.
Definition: Engine.cpp:66
void setChannelFlowState(U8 channelId, Flow::T flowState)
Set channel flow state.
Definition: Engine.cpp:671
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.
Definition: Engine.cpp:597
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
Definition: Queue.cpp:54
T
The raw enum type.
void log_WARNING_LO_UnsupportedSendFileArguments(U32 offset, U32 length) const
Log event UnsupportedSendFileArguments.
Generic CFDP error return code.
void teardown() override
teardown the queue
Definition: Queue.cpp:49
const char * toChar() const
Convert to a C-style char*.
enum T e
The raw enum value.
Enabled and disabled states.
Command successfully executed.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
void dataOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port dataOut.
CFDP operation has been successful.
void bufferDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port bufferDeallocate.
FwSizeType getSize() const
Definition: Buffer.cpp:60
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.
Definition: Engine.cpp:951
Memory Allocation base class.
void log_WARNING_LO_BuffersExhausted() const
Log event BuffersExhausted.
PlatformIndexType FwIndexType
Transaction initiated via port interface.
Send file response struct.
void set_context(U32 context)
Set member context.
void incrementOutgoingCounter()
Increment the outgoing PDU counter.
Definition: Channel.hpp:190
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
Definition: Queue.hpp:31
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.
Definition: Engine.cpp:676
U32 getMaxOutgoingPdusPerCycleParam(U8 channelIndex)
Fw::String getTmpDirParam(U8 channelIndex)
void cleanup()
Cleanup CFDP engine and deallocate resources.
Definition: CfdpManager.cpp:64
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.
Definition: Engine.cpp:711
Send PDU: No send buffer available, throttling limit reached.
T
The raw enum type.
Definition: ClassEnumAc.hpp:42
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.
Definition: Engine.cpp:855
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void log_ACTIVITY_LO_PollDirStopped(U8 channelId, U8 pollId) const
Log event PollDirStopped.