VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::mavlink::Checksum Class Reference

Mavlink compatible checksum (ITU X.25/SAE AS-4 hash) calculation class. More...

#include <mavlink.h>

Classes

struct  Exception_dummy_struct
 Base class for exceptions thrown by this class. More...
 
struct  Invalid_id_exception_dummy_struct
 Exception for unknown message ID. More...
 

Public Types

typedef ugcs::vsm::Param_exception< Exception_dummy_struct,> Exception
 
typedef ugcs::vsm::Derived_exception< Exception, Invalid_id_exception_dummy_structInvalid_id_exception
 Definition of a new exception type. More...
 

Public Member Functions

 Checksum ()
 Instance initialized with initial checksum value for empty buffer. More...
 
 Checksum (const void *buffer, size_t len)
 Instance initialized and checksum is calculated based on provided buffer. More...
 
 Checksum (const Io_buffer::Ptr &buffer)
 Instance initialized and checksum is calculated based on provided buffer. More...
 
uint16_t Accumulate (const void *buffer, size_t len)
 Incrementally calculate the checksum of a new buffer and accumulate it to the current value. More...
 
uint16_t Accumulate (const Io_buffer::Ptr &buffer)
 Incrementally calculate the checksum of a new buffer and accumulate it to the current value. More...
 
uint16_t Accumulate (uint8_t byte)
 Incrementally calculate the checksum of one new byte and accumulate it to the current value. More...
 
uint16_t Get () const
 Get current checksum value. More...
 
void Reset ()
 Reset checksum to initial seed value for zero-length buffer. More...
 

Static Public Member Functions

static uint16_t Calculate (const void *buffer, size_t len, uint16_t *accumulator=nullptr)
 Calculate checksum either incrementally or from initial seed value. More...
 
static bool Get_extra_byte_length_pair (MESSAGE_ID_TYPE message_id, Extra_byte_length_pair &ret, const Extension &ext=Extension::Get())
 Get CRC extra byte and expected payload length of a specific Mavlink message type. More...
 

Detailed Description

Mavlink compatible checksum (ITU X.25/SAE AS-4 hash) calculation class.

It can be used statically to calculate checksum of arbitrary buffer, or used as an instance to incrementally accumulate checksum for multiple buffers.

Member Typedef Documentation

Constructor & Destructor Documentation

ugcs::vsm::mavlink::Checksum::Checksum ( )

Instance initialized with initial checksum value for empty buffer.

ugcs::vsm::mavlink::Checksum::Checksum ( const void *  buffer,
size_t  len 
)

Instance initialized and checksum is calculated based on provided buffer.

ugcs::vsm::mavlink::Checksum::Checksum ( const Io_buffer::Ptr buffer)

Instance initialized and checksum is calculated based on provided buffer.

Member Function Documentation

uint16_t ugcs::vsm::mavlink::Checksum::Accumulate ( const void *  buffer,
size_t  len 
)

Incrementally calculate the checksum of a new buffer and accumulate it to the current value.

Parameters
bufferByte buffer.
lenSize of the buffer.
Returns
New checksum value.
uint16_t ugcs::vsm::mavlink::Checksum::Accumulate ( const Io_buffer::Ptr buffer)

Incrementally calculate the checksum of a new buffer and accumulate it to the current value.

Parameters
bufferByte buffer.
Returns
New checksum value.
uint16_t ugcs::vsm::mavlink::Checksum::Accumulate ( uint8_t  byte)

Incrementally calculate the checksum of one new byte and accumulate it to the current value.

Parameters
bytebyte.
Returns
New checksum value.
static uint16_t ugcs::vsm::mavlink::Checksum::Calculate ( const void *  buffer,
size_t  len,
uint16_t *  accumulator = nullptr 
)
static

Calculate checksum either incrementally or from initial seed value.

Parameters
bufferByte buffer.
lenSize of the buffer.
accumulatorIf not nullptr, then incremental calculation is made, otherwise initial seed value is used.
Returns
Calculated checksum value.
uint16_t ugcs::vsm::mavlink::Checksum::Get ( ) const

Get current checksum value.

static bool ugcs::vsm::mavlink::Checksum::Get_extra_byte_length_pair ( MESSAGE_ID_TYPE  message_id,
Extra_byte_length_pair ret,
const Extension ext = Extension::Get() 
)
static

Get CRC extra byte and expected payload length of a specific Mavlink message type.

Exceptions
Invalid_id_exceptionfor unknown Mavlink messages.
Parameters
message_idMavlink message id.
ret[out] CRC extra byte and length pair mavlink::Extra_byte_length_pair.
extExtension the message belongs to.
Returns
false if message_id is not recognized.
void ugcs::vsm::mavlink::Checksum::Reset ( )

Reset checksum to initial seed value for zero-length buffer.


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