mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 17:47:10 -06:00
* Initial FprimeFramer and FprimePacketizer * Code clarity + set up UTs * Rework ComQueue and ComStub to use DataWithContext * Add packets to RefPackets.fppi * Fix ComQueue tests * Add hotfix to FileDownlink instead of ComQueue * Fix cancelPacket as well * Fix ComQueue UTs by removing hotfix * Refactor DataWithContext to use an FPP object for context instead of Fw.Buffer * Touch up testing * Add docs * more docs * More docs * Rework buffer deallocation pattern to pass-through ComQueue * Update ComStub UTs * Restore original FileDownlink.cpp * Formatting tweak * Update deprecated getSerializeRepr() calls * deserialization methods * Fix spelling * add cast for safety * CMakefile change * Bump ComQueue depth * Update RPI deployment with new Downlink stack * Rename comQueueIn port to comPktQueueIn * Fix comQueueIn to comPktQueueIn change * Remove legacy Svc.Framer * Fix CMake UTs * Fix RPI topology config * Fix FprimeProtocol.fpp module * Fix namespacing * Use const reference for FrameContext port * Review comments EXCEPT port passback refactor * Rework ComStub with new ByteStream * New ByteStream - ComInterface model * Rework TcpClient / TcpServer with new bytestream * Adapt UDP component for new ByteStream * Adapt FrameAccumulator for new ByteStream * Adapt FprimeFramer for new ByteStream * Update Ref topology with new ByteStream model * Remove all legacy deallocates from Drivers; reintroduce DEPRECATED model types * Fix spelling and include error * More spelling.... * RPI and RpiDemo fixes * Fix conversion warning on RPI * static_cast for short int on RPI * Standardize port names * Remove legacy Drv types and merge RECV/SEND enum type, delete StreamCrossover * Update SDDs * Update SDDs * Fix ComInterface <-> Framer interfaction, clarify comments and fix annotations * Switch ComStub from ASSERT to log failure and return buffer * Add history size check + clarify test handler overrides * Fix RPI topology to wire comStub on Uplink * Rename comm to comDriver in RPI topology * Update communication adapter interface docs
74 lines
3.3 KiB
C++
74 lines
3.3 KiB
C++
// ======================================================================
|
|
// \title ComStub.cpp
|
|
// \author mstarch
|
|
// \brief cpp file for ComStub component implementation class
|
|
// ======================================================================
|
|
|
|
#include <Svc/ComStub/ComStub.hpp>
|
|
#include <Fw/Logger/Logger.hpp>
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "Fw/Types/BasicTypes.hpp"
|
|
|
|
namespace Svc {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction, initialization, and destruction
|
|
// ----------------------------------------------------------------------
|
|
|
|
ComStub::ComStub(const char* const compName) : ComStubComponentBase(compName), m_reinitialize(true), m_retry_count(0) {}
|
|
|
|
ComStub::~ComStub() {}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Handler implementations for user-defined typed input ports
|
|
// ----------------------------------------------------------------------
|
|
|
|
void ComStub::comDataIn_handler(const FwIndexType portNum, Fw::Buffer& sendBuffer, const ComCfg::FrameContext& context) {
|
|
FW_ASSERT(!this->m_reinitialize || !this->isConnected_comStatusOut_OutputPort(0)); // A message should never get here if we need to reinitialize is needed
|
|
this->m_storedContext = context; // Store the context of the current message
|
|
this->drvDataOut_out(0, sendBuffer);
|
|
}
|
|
|
|
void ComStub::drvConnected_handler(const FwIndexType portNum) {
|
|
Fw::Success radioSuccess = Fw::Success::SUCCESS;
|
|
if (this->isConnected_comStatusOut_OutputPort(0) && m_reinitialize) {
|
|
this->m_reinitialize = false;
|
|
this->comStatusOut_out(0, radioSuccess);
|
|
}
|
|
}
|
|
|
|
void ComStub::drvDataIn_handler(const FwIndexType portNum,
|
|
Fw::Buffer& recvBuffer,
|
|
const Drv::ByteStreamStatus& recvStatus) {
|
|
if (recvStatus.e == Drv::ByteStreamStatus::OP_OK) {
|
|
this->comDataOut_out(0, recvBuffer);
|
|
}
|
|
}
|
|
|
|
void ComStub ::dataReturnIn_handler(FwIndexType portNum, //!< The port number
|
|
Fw::Buffer& fwBuffer, //!< The buffer
|
|
const Drv::ByteStreamStatus& sendStatus) {
|
|
if (sendStatus != Drv::ByteStreamStatus::SEND_RETRY) {
|
|
// Not retrying - return buffer ownership and send status
|
|
this->dataReturnOut_out(0, fwBuffer, this->m_storedContext);
|
|
this->m_reinitialize = sendStatus.e != Drv::ByteStreamStatus::OP_OK;
|
|
this->m_retry_count = 0; // Reset the retry count
|
|
Fw::Success comSuccess = (sendStatus.e == Drv::ByteStreamStatus::OP_OK) ? Fw::Success::SUCCESS : Fw::Success::FAILURE;
|
|
this->comStatusOut_out(0, comSuccess);
|
|
} else {
|
|
// Driver indicates we should retry (SEND_RETRY)
|
|
if (this->m_retry_count < this->RETRY_LIMIT) {
|
|
// If we have not yet retried more than the retry limit, attempt to retry
|
|
this->m_retry_count++;
|
|
this->drvDataOut_out(0, fwBuffer);
|
|
} else {
|
|
// If retried too many times, return buffer and log failure
|
|
this->dataReturnOut_out(0, fwBuffer, this->m_storedContext);
|
|
Fw::Logger::log("ComStub RETRY_LIMIT exceeded, skipped sending data");
|
|
this->m_retry_count = 0; // Reset the retry count
|
|
}
|
|
}
|
|
}
|
|
|
|
} // end namespace Svc
|