![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol. More...
#include <CFDP/Checksum/Checksum.hpp>
Public Member Functions | |
Checksum () | |
Construct a fresh Checksum object. More... | |
Checksum (const U32 value) | |
Construct a Checksum object and initialize it with a value. More... | |
Checksum (const Checksum &original) | |
Copy a Checksum object. More... | |
~Checksum () | |
Destroy a Checksum object. More... | |
Checksum & | operator= (const Checksum &checksum) |
Assign checksum to this. More... | |
bool | operator== (const Checksum &checksum) const |
Compare checksum and this for equality. More... | |
bool | operator!= (const Checksum &checksum) const |
Compare checksum and this for inequality. More... | |
void | update (const U8 *const data, const U32 offset, const U32 length) |
U32 | getValue () const |
Get the checksum value. More... | |
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol.
This checksum is calculated by update of an existing 32-bit value with the "next" 32-bit string drawn from the file data. Beginning at the start of the file, a 4-byte window moves up the file by four bytes per update. The update itself replaces the existing checksum with the byte-wise sum of the existing checksum and the file data contained in the window. Overflows in the addition are permitted and the carry discarded.
If an update is to be made beginning at an offset into the file which is not aligned to a 4-byte boundary, the window is treated as beginning at the last 4-byte boundary, but is left-zero-padded. Similarly, where the file data for an update ends on an unaligned byte, the window extends up to the next boundary and is right-zero-padded.
For buffer 0xDE 0xAD 0xBE 0xEF 0xCA 0xFE and initial zero checksum:
---------------------------------— Update 1 Window 0xDE 0xAD 0xBE 0xEF Checksum 0xDEADBEEF
---------------------------------— Update 2 Window 0xCA 0xFE Checksum 0xDEADBEEF+
0xA8ABBEEF <- Final value
Definition at line 53 of file Checksum.hpp.
CFDP::Checksum::Checksum | ( | ) |
Construct a fresh Checksum object.
Definition at line 23 of file Checksum.cpp.
CFDP::Checksum::Checksum | ( | const U32 | value | ) |
Construct a Checksum object and initialize it with a value.
Definition at line 29 of file Checksum.cpp.
CFDP::Checksum::Checksum | ( | const Checksum & | original | ) |
Copy a Checksum object.
Definition at line 35 of file Checksum.cpp.
CFDP::Checksum::~Checksum | ( | ) |
Destroy a Checksum object.
Definition at line 41 of file Checksum.cpp.
U32 CFDP::Checksum::getValue | ( | ) | const |
Get the checksum value.
Definition at line 66 of file Checksum.cpp.
bool CFDP::Checksum::operator!= | ( | const Checksum & | checksum | ) | const |
Compare checksum and this for inequality.
Definition at line 60 of file Checksum.cpp.
Assign checksum to this.
Definition at line 47 of file Checksum.cpp.
bool CFDP::Checksum::operator== | ( | const Checksum & | checksum | ) | const |
Compare checksum and this for equality.
Definition at line 54 of file Checksum.cpp.
void CFDP::Checksum::update | ( | const U8 *const | data, |
const U32 | offset, | ||
const U32 | length | ||
) |
Update the checksum value by accumulating words in the given data.
The data and data-length passed to this method are specifically those over which the update is made, rather than the entire file. Typically, therefore, data
will be a pointer to the byte given by the offset, e.g. &file_buffer[offset]
.
data | Beginning of the data over which to update. |
offset | Offset into the file at which the data begins. |
length | Length of the update data in bytes. |
Definition at line 72 of file Checksum.cpp.