| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <Fw/FPrimeBasicTypes.hpp> | ||
| 2 | #include <Fw/Types/Assert.hpp> | ||
| 3 | #include <Os/Console.hpp> | ||
| 4 | #include <Ref/SendBuffApp/SendBuffComponentImpl.hpp> | ||
| 5 | #include <cstring> | ||
| 6 | |||
| 7 | #include <cstdio> | ||
| 8 | |||
| 9 | #define DEBUG_LEVEL 1 | ||
| 10 | |||
| 11 | namespace Ref { | ||
| 12 | |||
| 13 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | SendBuffImpl::SendBuffImpl(const char* compName) : SendBuffComponentBase(compName) { |
| 14 | 1 | this->m_currPacketId = 0; | |
| 15 | 1 | this->m_invocations = 0; | |
| 16 | 1 | this->m_buffsSent = 0; | |
| 17 | 1 | this->m_errorsInjected = 0; | |
| 18 | 1 | this->m_injectError = false; | |
| 19 | 1 | this->m_sendPackets = false; | |
| 20 | 1 | this->m_currPacketId = 0; | |
| 21 | 1 | this->m_firstPacketSent = false; | |
| 22 |
1/1✓ Branch 1 taken 1 times.
|
1 | this->m_state = SendBuff_ActiveState::SEND_IDLE; |
| 23 | 1 | } | |
| 24 | |||
| 25 | 2 | SendBuffImpl::~SendBuffImpl() {} | |
| 26 | |||
| 27 | 118 | void SendBuffImpl::SchedIn_handler(FwIndexType portNum, U32 context) { | |
| 28 | // first, dequeue any messages | ||
| 29 | |||
| 30 | 118 | MsgDispatchStatus stat = MSG_DISPATCH_OK; | |
| 31 | |||
| 32 |
2/2✓ Branch 0 taken 118 times.
✓ Branch 1 taken 118 times.
|
236 | while (MSG_DISPATCH_OK == stat) { |
| 33 | 118 | stat = this->doDispatch(); | |
| 34 | 118 | FW_ASSERT(stat != MSG_DISPATCH_ERROR); | |
| 35 | } | ||
| 36 | |||
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
|
118 | if (this->m_sendPackets) { |
| 38 | // check to see if first | ||
| 39 | ✗ | if (!this->m_firstPacketSent) { | |
| 40 | ✗ | this->m_firstPacketSent = true; | |
| 41 | ✗ | this->log_ACTIVITY_HI_FirstPacketSent(this->m_currPacketId); | |
| 42 | ✗ | this->tlmWrite_NumErrorsInjected(this->m_errorsInjected); | |
| 43 | } | ||
| 44 | // reset buffer | ||
| 45 | ✗ | this->m_testBuff.resetSer(); | |
| 46 | // serialize packet id | ||
| 47 | ✗ | Fw::SerializeStatus serStat = this->m_testBuff.serializeFrom(this->m_currPacketId); | |
| 48 | ✗ | FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK); | |
| 49 | // increment packet id | ||
| 50 | ✗ | this->m_currPacketId++; | |
| 51 | ✗ | this->m_buffsSent++; | |
| 52 | // set telemetry | ||
| 53 | ✗ | this->tlmWrite_PacketsSent(this->m_buffsSent); | |
| 54 | // write data | ||
| 55 | U8 testData[24]; | ||
| 56 | ✗ | FwSizeType dataSize = static_cast<FwSizeType>(sizeof(testData)); | |
| 57 | ✗ | memset(testData, 0xFF, static_cast<size_t>(dataSize)); | |
| 58 | // compute checksum | ||
| 59 | ✗ | U32 csum = 0; | |
| 60 | ✗ | for (U32 byte = 0; byte < dataSize; byte++) { | |
| 61 | ✗ | csum += testData[byte]; | |
| 62 | } | ||
| 63 | // inject error, if requested | ||
| 64 | ✗ | if (this->m_injectError) { | |
| 65 | ✗ | this->m_injectError = false; | |
| 66 | ✗ | this->m_errorsInjected++; | |
| 67 | ✗ | testData[5] = 0; | |
| 68 | ✗ | this->log_WARNING_HI_PacketErrorInserted(this->m_currPacketId - 1); | |
| 69 | } | ||
| 70 | // serialize data | ||
| 71 | ✗ | serStat = this->m_testBuff.serializeFrom(testData, dataSize); | |
| 72 | ✗ | FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK); | |
| 73 | // serialize checksum | ||
| 74 | ✗ | serStat = this->m_testBuff.serializeFrom(csum); | |
| 75 | ✗ | FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK); | |
| 76 | // send data | ||
| 77 | ✗ | this->Data_out(0, this->m_testBuff); | |
| 78 | } | ||
| 79 | |||
| 80 | 118 | this->m_invocations++; | |
| 81 | |||
| 82 |
2/2✓ Branch 1 taken 118 times.
✓ Branch 4 taken 118 times.
|
118 | this->tlmWrite_SendState(this->m_state); |
| 83 | 118 | } | |
| 84 | |||
| 85 | ✗ | void SendBuffImpl::SB_START_PKTS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { | |
| 86 | ✗ | this->m_sendPackets = true; | |
| 87 | ✗ | this->m_state = SendBuff_ActiveState::SEND_ACTIVE; | |
| 88 | ✗ | this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | |
| 89 | ✗ | } | |
| 90 | |||
| 91 | ✗ | void SendBuffImpl::SB_INJECT_PKT_ERROR_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { | |
| 92 | ✗ | this->m_injectError = true; | |
| 93 | ✗ | this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | |
| 94 | ✗ | } | |
| 95 | |||
| 96 | ✗ | void SendBuffImpl::SB_GEN_FATAL_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/ | |
| 97 | U32 cmdSeq, /*!< The command sequence number*/ | ||
| 98 | U32 arg1, /*!< First FATAL Argument*/ | ||
| 99 | U32 arg2, /*!< Second FATAL Argument*/ | ||
| 100 | U32 arg3 /*!< Third FATAL Argument*/ | ||
| 101 | ) { | ||
| 102 | ✗ | this->log_FATAL_SendBuffFatal(arg1, arg2, arg3); | |
| 103 | ✗ | this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | |
| 104 | ✗ | } | |
| 105 | |||
| 106 | //! Handler for command SB_GEN_ASSERT | ||
| 107 | /* Generate an ASSERT */ | ||
| 108 | ✗ | void SendBuffImpl::SB_GEN_ASSERT_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/ | |
| 109 | U32 cmdSeq, /*!< The command sequence number*/ | ||
| 110 | U32 arg1, /*!< First ASSERT Argument*/ | ||
| 111 | U32 arg2, /*!< Second ASSERT Argument*/ | ||
| 112 | U32 arg3, /*!< Third ASSERT Argument*/ | ||
| 113 | U32 arg4, /*!< Fourth ASSERT Argument*/ | ||
| 114 | U32 arg5, /*!< Fifth ASSERT Argument*/ | ||
| 115 | U32 arg6 /*!< Sixth ASSERT Argument*/ | ||
| 116 | ) { | ||
| 117 | ✗ | FW_ASSERT(0, arg1, arg2, arg3, arg4, arg5, arg6); | |
| 118 | ✗ | this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | |
| 119 | ✗ | } | |
| 120 | |||
| 121 | 4 | void SendBuffImpl::parameterUpdated(FwPrmIdType id) { | |
| 122 |
1/1✓ Branch 1 taken 4 times.
|
4 | this->log_ACTIVITY_LO_BuffSendParameterUpdated(id); |
| 123 |
1/1✓ Branch 1 taken 4 times.
|
4 | Fw::ParamValid valid; |
| 124 |
2/3✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | switch (id) { |
| 125 | 2 | case PARAMID_PARAMETER3: { | |
| 126 |
1/1✓ Branch 1 taken 2 times.
|
2 | U8 val = this->paramGet_parameter3(valid); |
| 127 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | this->tlmWrite_Parameter3(val); |
| 128 | 2 | break; | |
| 129 | } | ||
| 130 | 2 | case PARAMID_PARAMETER4: { | |
| 131 |
1/1✓ Branch 1 taken 2 times.
|
2 | F32 val = this->paramGet_parameter4(valid); |
| 132 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | this->tlmWrite_Parameter4(val); |
| 133 | 2 | break; | |
| 134 | } | ||
| 135 | ✗ | default: | |
| 136 | ✗ | FW_ASSERT(0, id); | |
| 137 | ✗ | break; | |
| 138 | } | ||
| 139 | 4 | } | |
| 140 | } // namespace Ref | ||
| 141 |