| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title ByteStreamBufferAdapter.cpp | ||
| 3 | // \author bocchino | ||
| 4 | // \brief cpp file for ByteStreamBufferAdapter component implementation class | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #include "Drv/ByteStreamBufferAdapter/ByteStreamBufferAdapter.hpp" | ||
| 8 | |||
| 9 | namespace Drv { | ||
| 10 | |||
| 11 | // ---------------------------------------------------------------------- | ||
| 12 | // Component construction and destruction | ||
| 13 | // ---------------------------------------------------------------------- | ||
| 14 | |||
| 15 | ✗ | ByteStreamBufferAdapter::ByteStreamBufferAdapter(const char* const compName) | |
| 16 | ✗ | : ByteStreamBufferAdapterComponentBase(compName) {} | |
| 17 | |||
| 18 | ✗ | ByteStreamBufferAdapter::~ByteStreamBufferAdapter() {} | |
| 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 { | |
| 31 | ✗ | this->log_WARNING_LO_DriverNotReady(); | |
| 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 | ||
| 59 |