| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title CfdpManager.hpp | ||
| 3 | // \author Brian Campuzano | ||
| 4 | // \brief hpp file for CfdpManager component implementation class | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #ifndef CCSDS_CFDPMANAGER_HPP | ||
| 8 | #define CCSDS_CFDPMANAGER_HPP | ||
| 9 | |||
| 10 | #include <Fw/Types/MemAllocator.hpp> | ||
| 11 | #include <Fw/Types/String.hpp> | ||
| 12 | #include <Os/Queue.hpp> | ||
| 13 | #include <Svc/Ccsds/CfdpManager/CfdpManagerComponentAc.hpp> | ||
| 14 | #include <Svc/Ccsds/CfdpManager/Types/StatusEnumAc.hpp> | ||
| 15 | |||
| 16 | namespace Svc { | ||
| 17 | namespace Ccsds { | ||
| 18 | namespace Cfdp { | ||
| 19 | |||
| 20 | // Forward declarations | ||
| 21 | class Engine; | ||
| 22 | class Channel; | ||
| 23 | class Transaction; | ||
| 24 | |||
| 25 | class CfdpManager final : public CfdpManagerComponentBase { | ||
| 26 | friend class CfdpManagerTester; | ||
| 27 | // Give access to protected functions for EVRs and Telemetry | ||
| 28 | friend class Engine; | ||
| 29 | friend class Channel; | ||
| 30 | friend class Transaction; | ||
| 31 | |||
| 32 | public: | ||
| 33 | // ---------------------------------------------------------------------- | ||
| 34 | // Component construction and destruction | ||
| 35 | // ---------------------------------------------------------------------- | ||
| 36 | |||
| 37 | //! Construct CfdpManager object | ||
| 38 | CfdpManager(const char* const compName //!< The component name | ||
| 39 | ); | ||
| 40 | |||
| 41 | //! Destroy CfdpManager object | ||
| 42 | ~CfdpManager(); | ||
| 43 | |||
| 44 | //! Configure CFDP engine | ||
| 45 | //! | ||
| 46 | //! Initializes the CFDP engine and allocates all memory resources needed | ||
| 47 | //! for CFDP operations including transactions, chunks, and histories. | ||
| 48 | //! Must be called once after construction and before any CFDP operations. | ||
| 49 | //! | ||
| 50 | //! \param allocator Memory allocator to use for Engine allocation | ||
| 51 | //! \param fileQueueDepth Depth of the fileIn request handoff queue | ||
| 52 | //! \param memId Allocator ID for deallocation | ||
| 53 | void configure(Fw::MemAllocator& allocator, FwSizeType fileQueueDepth, FwEnumStoreType memId = 0); | ||
| 54 | |||
| 55 | //! Cleanup CFDP engine and deallocate resources | ||
| 56 | void cleanup(); | ||
| 57 | |||
| 58 | //! Tear down the fileIn request queue | ||
| 59 | void deinit() override; | ||
| 60 | |||
| 61 | public: | ||
| 62 | // ---------------------------------------------------------------------- | ||
| 63 | // Constants | ||
| 64 | // ---------------------------------------------------------------------- | ||
| 65 | |||
| 66 | //! Size of packet descriptor prepended to PDUs for ComQueue | ||
| 67 | static constexpr FwSizeType PACKET_DESCRIPTOR_SIZE = sizeof(FwPacketDescriptorType); | ||
| 68 | |||
| 69 | // ---------------------------------------------------------------------- | ||
| 70 | // Port calls that are invoked by the CFDP engine | ||
| 71 | // These functions are analogous to the functions in cf_cfdp_sbintf.* | ||
| 72 | // However these functions are not direct ports due to the architectural | ||
| 73 | // differences between F' and cFE | ||
| 74 | // ---------------------------------------------------------------------- | ||
| 75 | |||
| 76 | //! Get a buffer for constructing an outgoing CFDP PDU | ||
| 77 | //! | ||
| 78 | //! Allocates a buffer from the downstream component for building a PDU. | ||
| 79 | //! Checks against the maximum number of PDUs allowed per cycle. | ||
| 80 | //! Equivalent to CF_CFDP_MsgOutGet in cFS. | ||
| 81 | //! | ||
| 82 | //! \param buffer [out] Buffer object to be populated with allocated memory | ||
| 83 | //! \param channel [in] Channel to allocate buffer for | ||
| 84 | //! \param size [in] Size of buffer needed in bytes | ||
| 85 | //! \return Status::SUCCESS if buffer allocated, Status::SEND_PDU_NO_BUF_AVAIL_ERROR otherwise | ||
| 86 | Status::T getPduBuffer(Fw::Buffer& buffer, Channel& channel, FwSizeType size); | ||
| 87 | |||
| 88 | //! Return an unused PDU buffer | ||
| 89 | //! | ||
| 90 | //! Deallocates a buffer that was obtained but not sent (e.g., due to error). | ||
| 91 | //! | ||
| 92 | //! \param channel [in] Channel that owns the buffer | ||
| 93 | //! \param pduBuffer [in] Buffer to return/deallocate | ||
| 94 | void returnPduBuffer(Channel& channel, Fw::Buffer& pduBuffer); | ||
| 95 | |||
| 96 | //! Send a PDU buffer via output port | ||
| 97 | //! | ||
| 98 | //! Transmits a fully constructed PDU buffer via the dataOut port. | ||
| 99 | //! | ||
| 100 | //! \param channel [in] Channel to send on | ||
| 101 | //! \param pduBuffer [in] Buffer containing the PDU to send | ||
| 102 | void sendPduBuffer(Channel& channel, Fw::Buffer& pduBuffer); | ||
| 103 | |||
| 104 | //! Send file completion notification for port-initiated transfers | ||
| 105 | //! | ||
| 106 | //! Invokes the fileDoneOut output port with the transaction status. | ||
| 107 | //! | ||
| 108 | //! \param status Transaction completion status | ||
| 109 | void sendFileComplete(Svc::SendFileStatus::T status); | ||
| 110 | |||
| 111 | // ---------------------------------------------------------------- | ||
| 112 | // Telemetry helper methods (public for Engine/Transaction access) | ||
| 113 | // ---------------------------------------------------------------- | ||
| 114 | |||
| 115 | //! Increment receive error counter | ||
| 116 | ✗ | void incrementRecvErrors(U8 chanId) { | |
| 117 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 118 | ✗ | m_channelTelemetry[chanId].set_recvErrors(m_channelTelemetry[chanId].get_recvErrors() + 1); | |
| 119 | ✗ | } | |
| 120 | |||
| 121 | //! Increment receive dropped counter | ||
| 122 | ✗ | void incrementRecvDropped(U8 chanId) { | |
| 123 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 124 | ✗ | m_channelTelemetry[chanId].set_recvDropped(m_channelTelemetry[chanId].get_recvDropped() + 1); | |
| 125 | ✗ | } | |
| 126 | |||
| 127 | //! Increment receive spurious counter | ||
| 128 | ✗ | void incrementRecvSpurious(U8 chanId) { | |
| 129 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 130 | ✗ | m_channelTelemetry[chanId].set_recvSpurious(m_channelTelemetry[chanId].get_recvSpurious() + 1); | |
| 131 | ✗ | } | |
| 132 | |||
| 133 | //! Add to received file data bytes | ||
| 134 | ✗ | void addRecvFileDataBytes(U8 chanId, U32 bytes) { | |
| 135 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 136 | ✗ | m_channelTelemetry[chanId].set_recvFileDataBytes(m_channelTelemetry[chanId].get_recvFileDataBytes() + bytes); | |
| 137 | ✗ | } | |
| 138 | |||
| 139 | //! Add to received NAK segment requests | ||
| 140 | ✗ | void addRecvNakSegmentRequests(U8 chanId, U32 count) { | |
| 141 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 142 | ✗ | m_channelTelemetry[chanId].set_recvNakSegmentRequests(m_channelTelemetry[chanId].get_recvNakSegmentRequests() + | |
| 143 | count); | ||
| 144 | ✗ | } | |
| 145 | |||
| 146 | //! Increment received PDU counter | ||
| 147 | ✗ | void incrementRecvPdu(U8 chanId) { | |
| 148 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 149 | ✗ | m_channelTelemetry[chanId].set_recvPdu(m_channelTelemetry[chanId].get_recvPdu() + 1); | |
| 150 | ✗ | } | |
| 151 | |||
| 152 | //! Increment receive EOF canceled counter | ||
| 153 | ✗ | void incrementRecvEofCanceled(U8 chanId) { | |
| 154 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 155 | ✗ | m_channelTelemetry[chanId].set_recvEofCanceled(m_channelTelemetry[chanId].get_recvEofCanceled() + 1); | |
| 156 | ✗ | } | |
| 157 | |||
| 158 | //! Add to sent NAK segment requests | ||
| 159 | ✗ | void addSentNakSegmentRequests(U8 chanId, U32 count) { | |
| 160 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 161 | ✗ | m_channelTelemetry[chanId].set_sentNakSegmentRequests(m_channelTelemetry[chanId].get_sentNakSegmentRequests() + | |
| 162 | count); | ||
| 163 | ✗ | } | |
| 164 | |||
| 165 | //! Add sent file data bytes | ||
| 166 | ✗ | void addSentFileDataBytes(U8 chanId, U32 bytes) { | |
| 167 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 168 | ✗ | m_channelTelemetry[chanId].set_sentFileDataBytes(m_channelTelemetry[chanId].get_sentFileDataBytes() + bytes); | |
| 169 | ✗ | } | |
| 170 | |||
| 171 | //! Increment sent PDU counter | ||
| 172 | ✗ | void incrementSentPdu(U8 chanId) { | |
| 173 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 174 | ✗ | m_channelTelemetry[chanId].set_sentPdu(m_channelTelemetry[chanId].get_sentPdu() + 1); | |
| 175 | ✗ | } | |
| 176 | |||
| 177 | //! Increment sent EOF canceled counter | ||
| 178 | ✗ | void incrementSentEofCanceled(U8 chanId) { | |
| 179 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 180 | ✗ | m_channelTelemetry[chanId].set_sentEofCanceled(m_channelTelemetry[chanId].get_sentEofCanceled() + 1); | |
| 181 | ✗ | } | |
| 182 | |||
| 183 | //! Increment fault ACK limit counter | ||
| 184 | ✗ | void incrementFaultAckLimit(U8 chanId) { | |
| 185 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 186 | ✗ | m_channelTelemetry[chanId].set_faultAckLimit(m_channelTelemetry[chanId].get_faultAckLimit() + 1); | |
| 187 | ✗ | } | |
| 188 | |||
| 189 | //! Increment fault NAK limit counter | ||
| 190 | ✗ | void incrementFaultNakLimit(U8 chanId) { | |
| 191 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 192 | ✗ | m_channelTelemetry[chanId].set_faultNakLimit(m_channelTelemetry[chanId].get_faultNakLimit() + 1); | |
| 193 | ✗ | } | |
| 194 | |||
| 195 | //! Increment fault inactivity timer counter | ||
| 196 | ✗ | void incrementFaultInactivityTimer(U8 chanId) { | |
| 197 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 198 | ✗ | m_channelTelemetry[chanId].set_faultInactivityTimer(m_channelTelemetry[chanId].get_faultInactivityTimer() + 1); | |
| 199 | ✗ | } | |
| 200 | |||
| 201 | //! Increment fault CRC mismatch counter | ||
| 202 | ✗ | void incrementFaultCrcMismatch(U8 chanId) { | |
| 203 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 204 | ✗ | m_channelTelemetry[chanId].set_faultCrcMismatch(m_channelTelemetry[chanId].get_faultCrcMismatch() + 1); | |
| 205 | ✗ | } | |
| 206 | |||
| 207 | //! Increment fault file size mismatch counter | ||
| 208 | ✗ | void incrementFaultFileSizeMismatch(U8 chanId) { | |
| 209 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 210 | ✗ | m_channelTelemetry[chanId].set_faultFileSizeMismatch(m_channelTelemetry[chanId].get_faultFileSizeMismatch() + | |
| 211 | 1); | ||
| 212 | ✗ | } | |
| 213 | |||
| 214 | //! Increment fault file open counter | ||
| 215 | ✗ | void incrementFaultFileOpen(U8 chanId) { | |
| 216 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 217 | ✗ | m_channelTelemetry[chanId].set_faultFileOpen(m_channelTelemetry[chanId].get_faultFileOpen() + 1); | |
| 218 | ✗ | } | |
| 219 | |||
| 220 | //! Increment fault file read counter | ||
| 221 | ✗ | void incrementFaultFileRead(U8 chanId) { | |
| 222 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 223 | ✗ | m_channelTelemetry[chanId].set_faultFileRead(m_channelTelemetry[chanId].get_faultFileRead() + 1); | |
| 224 | ✗ | } | |
| 225 | |||
| 226 | //! Increment fault file write counter | ||
| 227 | ✗ | void incrementFaultFileWrite(U8 chanId) { | |
| 228 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 229 | ✗ | m_channelTelemetry[chanId].set_faultFileWrite(m_channelTelemetry[chanId].get_faultFileWrite() + 1); | |
| 230 | ✗ | } | |
| 231 | |||
| 232 | //! Increment fault file seek counter | ||
| 233 | ✗ | void incrementFaultFileSeek(U8 chanId) { | |
| 234 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 235 | ✗ | m_channelTelemetry[chanId].set_faultFileSeek(m_channelTelemetry[chanId].get_faultFileSeek() + 1); | |
| 236 | ✗ | } | |
| 237 | |||
| 238 | //! Increment fault file rename counter | ||
| 239 | ✗ | void incrementFaultFileRename(U8 chanId) { | |
| 240 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 241 | ✗ | m_channelTelemetry[chanId].set_faultFileRename(m_channelTelemetry[chanId].get_faultFileRename() + 1); | |
| 242 | ✗ | } | |
| 243 | |||
| 244 | //! Increment fault directory read counter | ||
| 245 | ✗ | void incrementFaultDirectoryRead(U8 chanId) { | |
| 246 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 247 | ✗ | m_channelTelemetry[chanId].set_faultDirectoryRead(m_channelTelemetry[chanId].get_faultDirectoryRead() + 1); | |
| 248 | ✗ | } | |
| 249 | |||
| 250 | //! Increment receive EOF error counter (any condition code that is not no-error or cancel) | ||
| 251 | ✗ | void incrementFaultRxEofError(U8 chanId) { | |
| 252 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 253 | ✗ | m_channelTelemetry[chanId].set_faultRxEofError(m_channelTelemetry[chanId].get_faultRxEofError() + 1); | |
| 254 | ✗ | } | |
| 255 | |||
| 256 | //! Increment sent EOF error counter (any condition code that is not no-error or cancel) | ||
| 257 | ✗ | void incrementFaultTxEofError(U8 chanId) { | |
| 258 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 259 | ✗ | m_channelTelemetry[chanId].set_faultTxEofError(m_channelTelemetry[chanId].get_faultTxEofError() + 1); | |
| 260 | ✗ | } | |
| 261 | |||
| 262 | //! Get reference to channel telemetry for queue depth updates | ||
| 263 | ✗ | Cfdp::ChannelTelemetry& getChannelTelemetryRef(U8 chanId) { | |
| 264 | ✗ | FW_ASSERT(chanId < Cfdp::NumChannels, chanId); | |
| 265 | ✗ | return m_channelTelemetry[chanId]; | |
| 266 | } | ||
| 267 | |||
| 268 | private: | ||
| 269 | // ---------------------------------------------------------------------- | ||
| 270 | // Handler implementations for typed input ports | ||
| 271 | // ---------------------------------------------------------------------- | ||
| 272 | |||
| 273 | //! Handler implementation for run1Hz | ||
| 274 | //! | ||
| 275 | //! Run port which must be invoked at 1 Hz in order to satisfy CFDP timer logic | ||
| 276 | void run1Hz_handler(FwIndexType portNum, //!< The port number | ||
| 277 | U32 context //!< The call order | ||
| 278 | ) override; | ||
| 279 | |||
| 280 | //! Handler for input port dataReturnIn | ||
| 281 | void dataReturnIn_handler(FwIndexType portNum, //!< The port number | ||
| 282 | Fw::Buffer& fwBuffer) override; | ||
| 283 | |||
| 284 | //! Handler for input port dataIn | ||
| 285 | void dataIn_handler(FwIndexType portNum, //!< The port number | ||
| 286 | Fw::Buffer& fwBuffer //!< The buffer | ||
| 287 | ) override; | ||
| 288 | |||
| 289 | //! Handler for input port fileIn | ||
| 290 | Svc::SendFileResponse fileIn_handler(FwIndexType portNum, //!< The port number | ||
| 291 | const Fw::StringBase& sourceFileName, //!< Path of file to send | ||
| 292 | const Fw::StringBase& destFileName, //!< Path to store file at destination | ||
| 293 | U32 offset, //!< Byte offset to start reading from | ||
| 294 | U32 length //!< Number of bytes to read (0 = entire file) | ||
| 295 | ) override; | ||
| 296 | |||
| 297 | //! Handler for input port pingIn | ||
| 298 | void pingIn_handler(FwIndexType portNum, //!< The port number | ||
| 299 | U32 key //!< Value to return to pinger | ||
| 300 | ) override; | ||
| 301 | |||
| 302 | private: | ||
| 303 | // ---------------------------------------------------------------------- | ||
| 304 | // Handler implementations for commands | ||
| 305 | // ---------------------------------------------------------------------- | ||
| 306 | |||
| 307 | //! Handler for command SendFile | ||
| 308 | //! | ||
| 309 | //! Command to start a CFDP file transaction | ||
| 310 | void SendFile_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 311 | U32 cmdSeq, //!< The command sequence number | ||
| 312 | U8 channelId, //!< Channel ID for the file transaction | ||
| 313 | EntityId destId, //!< Destination entity id | ||
| 314 | const Class& cfdpClass, //!< CFDP class for the file transfer | ||
| 315 | const Keep& keep, //!< Whether or not to keep or delete the file upon completion | ||
| 316 | U8 priority, //!< Priority: 0=highest priority | ||
| 317 | const Fw::CmdStringArg& sourceFileName, //!< The name of the on-board file to send | ||
| 318 | const Fw::CmdStringArg& destFileName //!< The name of the destination file on the ground | ||
| 319 | ) override; | ||
| 320 | |||
| 321 | //! Handler for command PlaybackDirectory | ||
| 322 | //! | ||
| 323 | //! Command to start a directory playback | ||
| 324 | void PlaybackDirectory_cmdHandler( | ||
| 325 | FwOpcodeType opCode, //!< The opcode | ||
| 326 | U32 cmdSeq, //!< The command sequence number | ||
| 327 | U8 channelId, //!< Channel ID for the file transaction(s) | ||
| 328 | EntityId destId, //!< Destination entity id | ||
| 329 | const Class& cfdpClass, //!< CFDP class for the file transfer(s) | ||
| 330 | const Keep& keep, //!< Whether or not to keep or delete the file(s) upon completion | ||
| 331 | U8 priority, //!< Priority: 0=highest priority | ||
| 332 | const Fw::CmdStringArg& sourceDirectory, //!< The name of the on-board directory to send | ||
| 333 | const Fw::CmdStringArg& destDirectory //!< The name of the destination directory on the ground | ||
| 334 | ) override; | ||
| 335 | |||
| 336 | //! Handler for command PollDirectory | ||
| 337 | //! | ||
| 338 | //! Command to start a directory poll | ||
| 339 | void PollDirectory_cmdHandler( | ||
| 340 | FwOpcodeType opCode, //!< The opcode | ||
| 341 | U32 cmdSeq, //!< The command sequence number | ||
| 342 | U8 channelId, //!< Channel ID for the file transaction(s) | ||
| 343 | U8 pollId, //!< Channel poll ID for the file transaction(s) | ||
| 344 | EntityId destId, //!< Destination entity id | ||
| 345 | const Class& cfdpClass, //!< CFDP class for the file transfer(s) | ||
| 346 | U8 priority, //!< Priority: 0=highest priority | ||
| 347 | U32 interval, //!< Interval to poll the directory in seconds | ||
| 348 | const Fw::CmdStringArg& sourceDirectory, //!< The name of the on-board directory to send | ||
| 349 | const Fw::CmdStringArg& destDirectory //!< The name of the destination directory on the ground | ||
| 350 | ) override; | ||
| 351 | |||
| 352 | //! Handler for command StopPollDirectory | ||
| 353 | //! | ||
| 354 | //! Command to stop a directory poll | ||
| 355 | void StopPollDirectory_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 356 | U32 cmdSeq, //!< The command sequence number | ||
| 357 | U8 channelId, //!< Channel ID to stop | ||
| 358 | U8 pollId //!< Channel poll ID to stop | ||
| 359 | ) override; | ||
| 360 | |||
| 361 | //! Handler for command SetChannelFlow | ||
| 362 | //! | ||
| 363 | //! Command to set channel's flow status | ||
| 364 | void SetChannelFlow_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 365 | U32 cmdSeq, //!< The command sequence number | ||
| 366 | U8 channelId, //!< Channel ID to set | ||
| 367 | const Flow& freeze //!< Flow state to set | ||
| 368 | ) override; | ||
| 369 | |||
| 370 | //! Handler for command SuspendResumeTransaction | ||
| 371 | //! | ||
| 372 | //! Command to suspend or resume a transaction | ||
| 373 | void SuspendResumeTransaction_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 374 | U32 cmdSeq, //!< The command sequence number | ||
| 375 | U8 channelId, //!< Channel ID for the transaction | ||
| 376 | TransactionSeq transactionSeq, //!< Transaction sequence number | ||
| 377 | EntityId entityId, //!< Entity ID of the transaction | ||
| 378 | const SuspendResume& action //!< Action to take: SUSPEND or RESUME | ||
| 379 | ) override; | ||
| 380 | |||
| 381 | //! Handler for command CancelTransaction | ||
| 382 | //! | ||
| 383 | //! Command to cancel a transaction with graceful close-out | ||
| 384 | void CancelTransaction_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 385 | U32 cmdSeq, //!< The command sequence number | ||
| 386 | U8 channelId, //!< Channel ID for the transaction | ||
| 387 | TransactionSeq transactionSeq, //!< Transaction sequence number | ||
| 388 | EntityId entityId //!< Entity ID of the transaction | ||
| 389 | ) override; | ||
| 390 | |||
| 391 | //! Handler for command AbandonTransaction | ||
| 392 | //! | ||
| 393 | //! Command to abandon a transaction immediately | ||
| 394 | void AbandonTransaction_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 395 | U32 cmdSeq, //!< The command sequence number | ||
| 396 | U8 channelId, //!< Channel ID for the transaction | ||
| 397 | TransactionSeq transactionSeq, //!< Transaction sequence number | ||
| 398 | EntityId entityId //!< Entity ID of the transaction | ||
| 399 | ) override; | ||
| 400 | |||
| 401 | //! Handler for command ResetCounters | ||
| 402 | //! | ||
| 403 | //! Command to reset telemetry counters | ||
| 404 | void ResetCounters_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| 405 | U32 cmdSeq, //!< The command sequence number | ||
| 406 | U8 channelId //!< Channel ID to reset (0xFF for all channels) | ||
| 407 | ) override; | ||
| 408 | |||
| 409 | private: | ||
| 410 | // ---------------------------------------------------------------------- | ||
| 411 | // Private command helper functions | ||
| 412 | // ---------------------------------------------------------------------- | ||
| 413 | |||
| 414 | //! Drains the fileIn request queue and initiates the transfers on the active thread | ||
| 415 | //! | ||
| 416 | //! Called at the start of run1Hz, before the engine is cycled, so that all engine state | ||
| 417 | //! mutation happens on the component thread and never races the caller's thread. | ||
| 418 | void drainFileInQueue(); | ||
| 419 | |||
| 420 | //! Checks if the requested channel index is valid, and emits an EVR if not | ||
| 421 | Fw::CmdResponse::T checkCommandChannelIndex(U8 channelIndex //!< The channel index to check | ||
| 422 | ); | ||
| 423 | |||
| 424 | //! Checks if the requested channel poll index is valid, and emits an EVR if not | ||
| 425 | Fw::CmdResponse::T checkCommandChannelPollIndex(U8 pollIndex //!< The poll index to check | ||
| 426 | ); | ||
| 427 | |||
| 428 | //! Checks if the requested poll interval is valid (non-zero), and emits an EVR if not | ||
| 429 | Fw::CmdResponse::T checkCommandPollInterval(U32 interval //!< The poll interval to check | ||
| 430 | ); | ||
| 431 | |||
| 432 | public: | ||
| 433 | // ---------------------------------------------------------------------- | ||
| 434 | // Parameter helpers used by the CFDP engine | ||
| 435 | // ---------------------------------------------------------------------- | ||
| 436 | |||
| 437 | //! Get the local entity ID parameter | ||
| 438 | //! | ||
| 439 | //! \return The local CFDP entity ID | ||
| 440 | EntityId getLocalEidParam(void); | ||
| 441 | |||
| 442 | //! Get the outgoing file chunk size parameter | ||
| 443 | //! | ||
| 444 | //! \return Maximum size in bytes for file data segments in outgoing PDUs | ||
| 445 | U32 getOutgoingFileChunkSizeParam(void); | ||
| 446 | |||
| 447 | //! Get the RX CRC calculation bytes per scheduler cycle parameter | ||
| 448 | //! | ||
| 449 | //! \return Number of bytes to process per cycle when calculating received file CRC | ||
| 450 | U32 getRxCrcCalcBytesPerCycleParam(void); | ||
| 451 | |||
| 452 | //! Get the post-inactivity terminal-send retry budget parameter | ||
| 453 | //! | ||
| 454 | //! \return Number of extra cycles a pending terminal send is retried after inactivity fires | ||
| 455 | U8 getPostInactivitySendRetriesParam(void); | ||
| 456 | |||
| 457 | //! Get the temporary directory parameter for a channel | ||
| 458 | //! | ||
| 459 | //! \param channelIndex [in] Index of the channel | ||
| 460 | //! \return Path to temporary directory for in-progress file transfers | ||
| 461 | Fw::String getTmpDirParam(U8 channelIndex); | ||
| 462 | |||
| 463 | //! Get the failure directory parameter for a channel | ||
| 464 | //! | ||
| 465 | //! \param channelIndex [in] Index of the channel | ||
| 466 | //! \return Path to directory where failed transfers are moved | ||
| 467 | Fw::String getFailDirParam(U8 channelIndex); | ||
| 468 | |||
| 469 | //! Get the ACK limit parameter for a channel | ||
| 470 | //! | ||
| 471 | //! \param channelIndex [in] Index of the channel | ||
| 472 | //! \return Maximum number of times to retry sending an ACK PDU | ||
| 473 | U8 getAckLimitParam(U8 channelIndex); | ||
| 474 | |||
| 475 | //! Get the NAK limit parameter for a channel | ||
| 476 | //! | ||
| 477 | //! \param channelIndex [in] Index of the channel | ||
| 478 | //! \return Maximum number of times to retry sending a NAK PDU | ||
| 479 | U8 getNackLimitParam(U8 channelIndex); | ||
| 480 | |||
| 481 | //! Get the ACK timer parameter for a channel | ||
| 482 | //! | ||
| 483 | //! \param channelIndex [in] Index of the channel | ||
| 484 | //! \return ACK timeout value in seconds | ||
| 485 | U32 getAckTimerParam(U8 channelIndex); | ||
| 486 | |||
| 487 | //! Get the inactivity timer parameter for a channel | ||
| 488 | //! | ||
| 489 | //! \param channelIndex [in] Index of the channel | ||
| 490 | //! \return Inactivity timeout value in seconds | ||
| 491 | U32 getInactivityTimerParam(U8 channelIndex); | ||
| 492 | |||
| 493 | //! Get the dequeue enabled parameter for a channel | ||
| 494 | //! | ||
| 495 | //! \param channelIndex [in] Index of the channel | ||
| 496 | //! \return Whether the channel is enabled for dequeuing transactions | ||
| 497 | Fw::Enabled getDequeueEnabledParam(U8 channelIndex); | ||
| 498 | |||
| 499 | //! Get the move directory parameter for a channel | ||
| 500 | //! | ||
| 501 | //! \param channelIndex [in] Index of the channel | ||
| 502 | //! \return Path to directory where completed transfers are moved | ||
| 503 | Fw::String getMoveDirParam(U8 channelIndex); | ||
| 504 | |||
| 505 | //! Get the maximum outgoing PDUs per cycle parameter for a channel | ||
| 506 | //! | ||
| 507 | //! \param channelIndex [in] Index of the channel | ||
| 508 | //! \return Maximum number of PDUs that can be sent per engine cycle | ||
| 509 | U32 getMaxOutgoingPdusPerCycleParam(U8 channelIndex); | ||
| 510 | |||
| 511 | private: | ||
| 512 | // ---------------------------------------------------------------------- | ||
| 513 | // Types | ||
| 514 | // ---------------------------------------------------------------------- | ||
| 515 | |||
| 516 | //! A port-initiated file send request, copied into the internal queue by fileIn_handler | ||
| 517 | //! and consumed on the active thread in run1Hz. Fixed-size and trivially relocatable so it | ||
| 518 | //! can be transported through Os::Queue. | ||
| 519 | struct FileInRequest { | ||
| 520 | Fw::String sourceFileName; //!< Path of file to send | ||
| 521 | Fw::String destFileName; //!< Path to store file at destination | ||
| 522 | U32 context; //!< Port number of the originating fileIn request | ||
| 523 | }; | ||
| 524 | |||
| 525 | // ---------------------------------------------------------------------- | ||
| 526 | // Member variables | ||
| 527 | // ---------------------------------------------------------------------- | ||
| 528 | // CFDP Engine - owns all protocol state and operations | ||
| 529 | Engine* m_engine; | ||
| 530 | |||
| 531 | //! Queue of accepted port-initiated file send requests, drained on the active thread | ||
| 532 | Os::Queue m_fileInQueue; | ||
| 533 | |||
| 534 | //! Depth of the fileIn request handoff queue, also the max drained per cycle. Set at | ||
| 535 | //! configure time from the fileQueueDepth argument. | ||
| 536 | FwSizeType m_fileInQueueDepth = 0; | ||
| 537 | |||
| 538 | //! Telemetry array for all CFDP channels | ||
| 539 | Cfdp::ChannelTelemetryArray m_channelTelemetry; | ||
| 540 | |||
| 541 | //! Stored for cleanup | ||
| 542 | FwEnumStoreType m_allocatorId = 0; | ||
| 543 | Fw::MemAllocator* m_allocator = nullptr; | ||
| 544 | }; | ||
| 545 | |||
| 546 | } // namespace Cfdp | ||
| 547 | } // namespace Ccsds | ||
| 548 | } // namespace Svc | ||
| 549 | |||
| 550 | #endif // CCSDS_CFDPMANAGER_HPP | ||
| 551 |