| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Header.cpp | ||
| 3 | // \author bocchino | ||
| 4 | // \brief cpp file for FilePacket::Header | ||
| 5 | // | ||
| 6 | // \copyright | ||
| 7 | // Copyright 2009-2016, by the California Institute of Technology. | ||
| 8 | // ALL RIGHTS RESERVED. United States Government Sponsorship | ||
| 9 | // acknowledged. | ||
| 10 | // | ||
| 11 | // ====================================================================== | ||
| 12 | |||
| 13 | #include <Fw/FilePacket/FilePacket.hpp> | ||
| 14 | #include <Fw/Types/Assert.hpp> | ||
| 15 | |||
| 16 | namespace Fw { | ||
| 17 | |||
| 18 | 48 | void FilePacket::Header ::initialize(const Type type, const U32 sequenceIndex) { | |
| 19 | 48 | this->m_type = type; | |
| 20 | 48 | this->m_sequenceIndex = sequenceIndex; | |
| 21 | 48 | } | |
| 22 | |||
| 23 | 63 | U32 FilePacket::Header ::bufferSize() const { | |
| 24 | 63 | return sizeof(U8) + sizeof(this->m_sequenceIndex); | |
| 25 | } | ||
| 26 | |||
| 27 | 44 | SerializeStatus FilePacket::Header ::fromSerialBuffer(SerialBuffer& serialBuffer) { | |
| 28 | 44 | U8 new_type; | |
| 29 | SerializeStatus status; | ||
| 30 | |||
| 31 |
1/1✓ Branch 5 taken 44 times.
|
44 | status = serialBuffer.deserializeTo(new_type); |
| 32 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
|
44 | if (status != FW_SERIALIZE_OK) { |
| 33 | ✗ | return status; | |
| 34 | } | ||
| 35 | 44 | this->m_type = static_cast<Type>(new_type); | |
| 36 | |||
| 37 |
1/1✓ Branch 8 taken 44 times.
|
44 | status = serialBuffer.deserializeTo(this->m_sequenceIndex); |
| 38 | |||
| 39 | 44 | return status; | |
| 40 | } | ||
| 41 | |||
| 42 | 46 | SerializeStatus FilePacket::Header ::toSerialBuffer(SerialBuffer& serialBuffer) const { | |
| 43 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
|
46 | const U8 type_casted = static_cast<U8>(this->m_type); |
| 44 | SerializeStatus status; | ||
| 45 | |||
| 46 | 46 | status = serialBuffer.serializeFrom(type_casted); | |
| 47 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
|
46 | if (status != FW_SERIALIZE_OK) { |
| 48 | ✗ | return status; | |
| 49 | } | ||
| 50 | |||
| 51 | 46 | status = serialBuffer.serializeFrom(this->m_sequenceIndex); | |
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
|
46 | if (status != FW_SERIALIZE_OK) { |
| 53 | ✗ | return status; | |
| 54 | } | ||
| 55 | |||
| 56 | 46 | return FW_SERIALIZE_OK; | |
| 57 | } | ||
| 58 | |||
| 59 | } // namespace Fw | ||
| 60 |