| 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 | 4 | ByteStreamBufferAdapter::ByteStreamBufferAdapter(const char* const compName) | |
| 16 | 4 | : ByteStreamBufferAdapterComponentBase(compName) {} | |
| 17 | |||
| 18 | 8 | ByteStreamBufferAdapter::~ByteStreamBufferAdapter() {} | |
| 19 | |||
| 20 | // ---------------------------------------------------------------------- | ||
| 21 | // Handler implementations for typed input ports | ||
| 22 | // ---------------------------------------------------------------------- | ||
| 23 | |||
| 24 | 5 | void ByteStreamBufferAdapter::bufferIn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) { | |
| 25 |
2/2✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2 times.
|
5 | if (this->m_driverIsReady) { |
| 26 |
1/1✓ Branch 3 taken 3 times.
|
3 | Drv::ByteStreamStatus status = toByteStreamDriver_out(portNum, fwBuffer); |
| 27 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
3 | if (status != Drv::ByteStreamStatus::OP_OK) { |
| 28 |
1/1✓ Branch 7 taken 1 times.
|
1 | this->log_WARNING_LO_DataSendError(status); |
| 29 | } | ||
| 30 | 3 | } else { | |
| 31 | 2 | this->log_WARNING_LO_DriverNotReady(); | |
| 32 | } | ||
| 33 | // ByteStreamDriver is Sync, so we return buffer back immediately regardless of status/readiness | ||
| 34 | 5 | this->bufferInReturn_out(portNum, fwBuffer); | |
| 35 | 5 | } | |
| 36 | |||
| 37 | 1 | void ByteStreamBufferAdapter::bufferOutReturn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) { | |
| 38 | 1 | this->fromByteStreamDriverReturn_out(portNum, fwBuffer); | |
| 39 | 1 | } | |
| 40 | |||
| 41 | 2 | void ByteStreamBufferAdapter::fromByteStreamDriver_handler(FwIndexType portNum, | |
| 42 | Fw::Buffer& buffer, | ||
| 43 | const Drv::ByteStreamStatus& status) { | ||
| 44 |
2/2✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | if (status == Drv::ByteStreamStatus::OP_OK) { |
| 45 | 1 | 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 | 1 | this->log_WARNING_LO_DataReceiveError(status); | |
| 50 | 1 | this->fromByteStreamDriverReturn_out(portNum, buffer); | |
| 51 | } | ||
| 52 | 2 | } | |
| 53 | |||
| 54 | 3 | void ByteStreamBufferAdapter::byteStreamDriverReady_handler(FwIndexType portNum) { | |
| 55 | 3 | this->m_driverIsReady = true; | |
| 56 | 3 | } | |
| 57 | |||
| 58 | } // namespace Drv | ||
| 59 |