F´ Flight Software - C/C++ Documentation
NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
|
Go to the documentation of this file.
16 static U32
min(
const U32 a,
const U32 b) {
17 return (a < b) ? a : b;
29 Checksum(
const U32 value) : value(value)
49 this->value = checksum.value;
56 return this->value == checksum.value;
62 return not (*
this == checksum);
81 const U32 offsetMod4 = offset % 4;
82 if (offsetMod4 != 0) {
83 const U8 wordLength =
static_cast<U8>(
min(length, 4 - offsetMod4));
86 static_cast<U8>(offset + index),
93 for ( ; index + 4 <= length; index += 4)
94 addWordAligned(&data[index]);
98 const U8 wordLength =
static_cast<U8>(length - index);
101 static_cast<U8>(offset + index),
109 addWordAligned(
const U8 *
const word)
111 for (
U8 i = 0; i < 4; ++i)
123 U8 offset = position % 4;
124 for (
U8 i = 0; i < length; ++i) {
139 const U32 addend =
byte << (8*(3-offset));
140 this->value += addend;
bool operator!=(const Checksum &checksum) const
Compare checksum and this for inequality.
uint8_t U8
8-bit unsigned integer
void update(const U8 *const data, const U32 offset, const U32 length)
Update the checksum value by accumulating the words in the data.
void addByteAtOffset(const U8 byte, const U8 offset)
Add byte to value at offset in word.
U32 getValue(void) const
Get the checksum value.
Checksum()
Construct a fresh Checksum object.
void addWordUnaligned(const U8 *const word, const U8 position, const U8 length)
Add a four-byte unaligned word to the checksum value.
const Checksum & operator=(const Checksum &checksum)
Assign checksum to this.
bool operator==(const Checksum &checksum) const
Comapre checksum and this for equality.
static U32 min(const U32 a, const U32 b)
~Checksum()
Destroy a Checksum object.
Class representing a CFDP checksum.