| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title AsyncByteStreamBufferAdapter.cpp | ||
| 3 | // \author shahab | ||
| 4 | // \brief cpp file for AsyncByteStreamBufferAdapter component implementation class | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #include "Drv/AsyncByteStreamBufferAdapter/AsyncByteStreamBufferAdapter.hpp" | ||
| 8 | |||
| 9 | namespace Drv { | ||
| 10 | |||
| 11 | // ---------------------------------------------------------------------- | ||
| 12 | // Component construction and destruction | ||
| 13 | // ---------------------------------------------------------------------- | ||
| 14 | |||
| 15 | 3 | AsyncByteStreamBufferAdapter ::AsyncByteStreamBufferAdapter(const char* const compName) | |
| 16 | 3 | : AsyncByteStreamBufferAdapterComponentBase(compName) {} | |
| 17 | |||
| 18 | 6 | AsyncByteStreamBufferAdapter ::~AsyncByteStreamBufferAdapter() {} | |
| 19 | |||
| 20 | // ---------------------------------------------------------------------- | ||
| 21 | // Handler implementations for typed input ports | ||
| 22 | // ---------------------------------------------------------------------- | ||
| 23 | |||
| 24 | 3 | void AsyncByteStreamBufferAdapter ::bufferIn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) { | |
| 25 |
2/2✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
|
3 | if (this->m_driverIsReady) { |
| 26 | 2 | this->toByteStreamDriver_out(portNum, fwBuffer); | |
| 27 | // ByteStreamDriver is Async; don't return buffer here but wait for toByteStreamDriverReturn | ||
| 28 | } else { | ||
| 29 | // If not ready, log warning and return buffer back immediately | ||
| 30 | 1 | this->log_WARNING_LO_DriverNotReady(); | |
| 31 | 1 | this->bufferInReturn_out(portNum, fwBuffer); | |
| 32 | } | ||
| 33 | 3 | } | |
| 34 | |||
| 35 | 2 | void AsyncByteStreamBufferAdapter ::bufferOutReturn_handler(FwIndexType portNum, Fw::Buffer& fwBuffer) { | |
| 36 | 2 | this->fromByteStreamDriverReturn_out(portNum, fwBuffer); | |
| 37 | 2 | } | |
| 38 | |||
| 39 | 2 | void AsyncByteStreamBufferAdapter ::fromByteStreamDriver_handler(FwIndexType portNum, | |
| 40 | Fw::Buffer& buffer, | ||
| 41 | const Drv::ByteStreamStatus& status) { | ||
| 42 |
2/2✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | if (status == Drv::ByteStreamStatus::OP_OK) { |
| 43 | 1 | this->bufferOut_out(portNum, buffer); | |
| 44 | // buffer ownership will come back through bufferOutReturn so we do **not** return buffer here | ||
| 45 | } else { | ||
| 46 | // If error, log and return buffer back immediately | ||
| 47 | 1 | this->log_WARNING_LO_DataReceiveError(status); | |
| 48 | 1 | this->fromByteStreamDriverReturn_out(portNum, buffer); | |
| 49 | } | ||
| 50 | 2 | } | |
| 51 | |||
| 52 | 3 | void AsyncByteStreamBufferAdapter ::byteStreamDriverReady_handler(FwIndexType portNum) { | |
| 53 | 3 | this->m_driverIsReady = true; | |
| 54 | 3 | } | |
| 55 | |||
| 56 | 2 | void AsyncByteStreamBufferAdapter ::toByteStreamDriverReturn_handler(FwIndexType portNum, | |
| 57 | Fw::Buffer& buffer, | ||
| 58 | const Drv::ByteStreamStatus& status) { | ||
| 59 |
2/2✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | if (status != Drv::ByteStreamStatus::OP_OK) { |
| 60 | 1 | this->log_WARNING_LO_DataSendError(status); | |
| 61 | } | ||
| 62 | 2 | this->bufferInReturn_out(portNum, buffer); | |
| 63 | 2 | } | |
| 64 | |||
| 65 | } // namespace Drv | ||
| 66 |