F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ByteStreamBufferAdapter.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ByteStreamBufferAdapter.cpp
3 // \author bocchino
4 // \brief cpp file for ByteStreamBufferAdapter component implementation class
5 // ======================================================================
6 
8 
9 namespace Drv {
10 
11 // ----------------------------------------------------------------------
12 // Component construction and destruction
13 // ----------------------------------------------------------------------
14 
17 
19 
20 // ----------------------------------------------------------------------
21 // Handler implementations for typed input ports
22 // ----------------------------------------------------------------------
23 
24 void ByteStreamBufferAdapter::bufferIn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) {
25  if (this->m_driverIsReady) {
26  Drv::ByteStreamStatus status = toByteStreamDriver_out(portNum, fwBuffer);
27  if (status != Drv::ByteStreamStatus::OP_OK) {
28  this->log_WARNING_LO_DataSendError(status);
29  }
30  } else {
32  }
33  // ByteStreamDriver is Sync, so we return buffer back immediately regardless of status/readiness
34  this->bufferInReturn_out(portNum, fwBuffer);
35 }
36 
37 void ByteStreamBufferAdapter::bufferOutReturn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) {
38  this->fromByteStreamDriverReturn_out(portNum, fwBuffer);
39 }
40 
41 void ByteStreamBufferAdapter::fromByteStreamDriver_handler(FwIndexType portNum,
42  Fw::Buffer& buffer,
43  const Drv::ByteStreamStatus& status) {
44  if (status == Drv::ByteStreamStatus::OP_OK) {
45  this->bufferOut_out(portNum, buffer);
46  // buffer ownership will come back through bufferOutReturn so we do **not** return buffer here
47  } else {
48  // If error, log and return buffer back immediately
49  this->log_WARNING_LO_DataReceiveError(status);
50  this->fromByteStreamDriverReturn_out(portNum, buffer);
51  }
52 }
53 
54 void ByteStreamBufferAdapter::byteStreamDriverReady_handler(FwIndexType portNum) {
55  this->m_driverIsReady = true;
56 }
57 
58 } // namespace Drv
Drv::ByteStreamStatus toByteStreamDriver_out(FwIndexType portNum, Fw::Buffer &sendBuffer)
Invoke output port toByteStreamDriver.
void fromByteStreamDriverReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port fromByteStreamDriverReturn.
Auto-generated base for ByteStreamBufferAdapter component.
Status returned by the send call.
Operation worked as expected.
void bufferInReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferInReturn.
ByteStreamBufferAdapter(const char *const compName)
Construct ByteStreamBufferAdapter object.
~ByteStreamBufferAdapter()
Destroy ByteStreamBufferAdapter object.
PlatformIndexType FwIndexType
void bufferOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferOut.