mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 17:47:10 -06:00
* lestarch: adding logical types implementation into Linux/StandardTypes.hpp * lestarch: removing VxWorks StandardTypes from repository * updated fprime types for correct compilation with vxworks and baremetal * lestarch: refactoring types and configuration header w.r.t type design * lestarch: replacing usages of AssertArg with FwAssertArgType * lestarch: missspelled configuration * lestarch: minor compilation fixes * lestarch: renaming StandardTypes.hpp -> PlatformTypes.hpp * lestarch: updating PRI tokens * lestarch: replacing BasicTypes.hpp includes with FpConfig.hpp * lestarch: UT and compilation fixes for types refactor * lestarch: sp * lestarch: fixing RPI issues in PassiveConsoleTextLogger * lestarch: converting RPI build to debug * lestarch: removing duplicate config imports * lestarch: fixing documentation * lestarch: fixing up multiple definitions and RPI compilation problems * lestarch: reverting debug build * lestarch: reverting platform types to class-based constants * lestarch: reworking basic types * lestarch: configured types refactor into classes * lestarch: fixing bugs with static constants in classes * lestarch: fixing platform types spelling and documentation * lestarch: adding include guards to types headers Co-authored-by: Kevin F Ortega <kevin.f.ortega@jpl.nasa.gov>
112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
// ======================================================================
|
|
// \title CFDP/Checksum/Checksum.hpp
|
|
// \author bocchino
|
|
// \brief hpp file for CFDP checksum class
|
|
//
|
|
// \copyright
|
|
// Copyright 2009-2016, by the California Institute of Technology.
|
|
// ALL RIGHTS RESERVED. United States Government Sponsorship
|
|
// acknowledged.
|
|
//
|
|
// ======================================================================
|
|
|
|
#ifndef CFDP_Checksum_HPP
|
|
#define CFDP_Checksum_HPP
|
|
|
|
#include <FpConfig.hpp>
|
|
|
|
namespace CFDP {
|
|
|
|
//! \class Checksum
|
|
//! \brief Class representing a CFDP checksum
|
|
//!
|
|
class Checksum {
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Types
|
|
// ----------------------------------------------------------------------
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction and destruction
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Construct a fresh Checksum object
|
|
Checksum();
|
|
|
|
//! Construct a Checksum object and initialize it with a value
|
|
Checksum(const U32 value);
|
|
|
|
//! Copy a Checksum object
|
|
Checksum(const Checksum &original);
|
|
|
|
//! Destroy a Checksum object
|
|
~Checksum();
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Public instance methods
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Assign checksum to this
|
|
Checksum& operator=(const Checksum& checksum);
|
|
|
|
//! Compare checksum and this for equality
|
|
bool operator==(const Checksum& checksum) const;
|
|
|
|
//! Compare checksum and this for inequality
|
|
bool operator!=(const Checksum& checksum) const;
|
|
|
|
//! Update the checksum value by accumulating the words in the data
|
|
void update(
|
|
const U8 *const data, //!< The data
|
|
const U32 offset, //!< The offset of the start of the data, relative to the start of the file
|
|
const U32 length //!< The length of the data in bytes
|
|
);
|
|
|
|
//! Get the checksum value
|
|
U32 getValue() const;
|
|
|
|
PRIVATE:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Private instance methods
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Add a four-byte aligned word to the checksum value
|
|
void addWordAligned(
|
|
const U8 *const word //! The word
|
|
);
|
|
|
|
//! Add a four-byte unaligned word to the checksum value
|
|
void addWordUnaligned(
|
|
const U8 *const word, //! The word
|
|
const U8 position, //! The position of the word relative to the start of the file
|
|
const U8 length //! The number of valid bytes in the word
|
|
);
|
|
|
|
//! Add byte to value at offset in word
|
|
void addByteAtOffset(
|
|
const U8 byte, //! The byte
|
|
const U8 offset //! The offset
|
|
);
|
|
|
|
PRIVATE:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Private member variables
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The accumulated checksum value
|
|
U32 value;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|