F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
CFDP::Checksum Class Reference

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...
 
Checksumoperator= (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Checksum() [1/3]

CFDP::Checksum::Checksum ( )

Construct a fresh Checksum object.

Definition at line 23 of file Checksum.cpp.

◆ Checksum() [2/3]

CFDP::Checksum::Checksum ( const U32  value)

Construct a Checksum object and initialize it with a value.

Definition at line 29 of file Checksum.cpp.

◆ Checksum() [3/3]

CFDP::Checksum::Checksum ( const Checksum original)

Copy a Checksum object.

Definition at line 35 of file Checksum.cpp.

◆ ~Checksum()

CFDP::Checksum::~Checksum ( )

Destroy a Checksum object.

Definition at line 41 of file Checksum.cpp.

Member Function Documentation

◆ getValue()

U32 CFDP::Checksum::getValue ( ) const

Get the checksum value.

Definition at line 66 of file Checksum.cpp.

◆ operator!=()

bool CFDP::Checksum::operator!= ( const Checksum checksum) const

Compare checksum and this for inequality.

Definition at line 60 of file Checksum.cpp.

◆ operator=()

Checksum & CFDP::Checksum::operator= ( const Checksum checksum)

Assign checksum to this.

Definition at line 47 of file Checksum.cpp.

◆ operator==()

bool CFDP::Checksum::operator== ( const Checksum checksum) const

Compare checksum and this for equality.

Definition at line 54 of file Checksum.cpp.

◆ update()

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].

Parameters
dataBeginning of the data over which to update.
offsetOffset into the file at which the data begins.
lengthLength of the update data in bytes.

Definition at line 72 of file Checksum.cpp.


The documentation for this class was generated from the following files: