GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > encdec / rhel4-32


Interface   Data Structures   File List   Data Fields   Globals  

FCS.h File Reference


Classes

struct  _FCS_checksum
 Structure to hold the context needed when forming the checksum over multiple arrays of data. More...

Typedefs

typedef struct _FCS_checksum FCS_checksum
 Typedef for struct _FCS_checksum.

Functions

unsigned int FCS_calculate16 (const unsigned short int *data, unsigned int cnt)
 Calculates the 32-bit Fletcher checksum over the 16-bit data array.
unsigned int FCS_calculate32 (const unsigned int *data, unsigned int cnt)
 Calculates the 32-bit Fletcher checksum over the 32-bit data array.
void FCS_construct (FCS_checksum *checksum)
 Constructs a Fletcher checksum context. This is used when the data to be checksummed is not in one contigious array.
void FCS_accumulate16 (FCS_checksum *checksum, const unsigned short int *data, unsigned int cnt)
 Updates the current Fletcher checksum.
void FCS_accumulate32 (FCS_checksum *checksum, const unsigned int *data, unsigned int cnt)
 Updates the current Fletcher checksum.
unsigned int FCS_get (const FCS_checksum *checksum)
 Processes the Fletcher checksum context, returning the current value of the checksum.

Detailed Description

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: FCS.h,v 1.1 2009/04/30 00:32:16 russell Exp $

Overview
Routines are provided to compute a 32-bit Fletcher checksum over both arrays of 16-bit and 32-bit integers. In addition, two sets of routines are provided
  • simplified routines to a contigious array of 16 or 32-bit integers
  • a set of routines to form the checksum over multiple arrays. This is useful if the data to be checksummed is not in contigious memory.
Example, Checksumming multiple arrays.
The following example would form the checksum over 3 arrays,
  • array_1 of 10 32-bit values
  • array_2 of 20 32-bit values
  • array_3 of 30 16-bit values and retrieve the final checksum.
         FCS_checksum      fcs;
         unsigned int checksum;

         FCS_checksumConstruct (&fcs);
         FCS_checksumUpdate32  (&fcs, array_1, 10);
         FCS_checksumUpdate32  (&fcs, array_2, 20);
         FCS_checksumUpdate16  (&fcs, array_3, 30);

         checksum = FCS_checksumGet (&fcs);

Note that this is checksum cannot be computed by separately forming checksums over the 3 arrays and then adding those 3 checksums together. Also note that one may freely mix checksums over 16-bit and 32-bit arrays.
Implementation note
The 32-bit Fletcher checksum is generally defined to be computed over an array of 16-bit integers. Here the algorithm is adapted to be computed over an array of 32-bit integers. The method is to treat the 32-bit integers as pairs of 16-bit integers. Because the Fletcher checksum is dependent on the ordering of the values being checksummed, one must decide the order to process the pair of 16-bit integers. It was decided to pick the ordering such that on one get the same answer if the 32-bit array was treated as a 16-bit array on a big-endian machine. It is an arbitrary choice, but once choosen must be adherred to when comparing checksums.
The code is such that the checksum will be the same when computed on both big and little endian machines.

Typedef Documentation

Typedef for struct _FCS_checksum.

The fields inside this data structure should never be manipulated by the user. The only reason it is provided as part of the public interface is so that the user may conveniently get an instance without doing an allocation.


Function Documentation

void FCS_accumulate16 ( FCS_checksum checksum,
const unsigned short int *  data,
unsigned int  cnt 
)

Updates the current Fletcher checksum.

Parameters:
checksum The Fletcher checksum context.
data The 16-bit data array to add to the current checksum
cnt The count of elements in data

References _FCS_checksum::left, _FCS_checksum::sum1, and _FCS_checksum::sum2.

void FCS_accumulate32 ( FCS_checksum checksum,
const unsigned int *  data,
unsigned int  cnt 
)

Updates the current Fletcher checksum.

Parameters:
checksum The Fletcher checksum context.
data The 32-bit data array to add to the current checksum
cnt The count of elements in data

References dprintf, _FCS_checksum::left, _FCS_checksum::sum1, and _FCS_checksum::sum2.

unsigned int FCS_calculate16 ( const unsigned short int *  data,
unsigned int  cnt 
)

Calculates the 32-bit Fletcher checksum over the 16-bit data array.

Returns:
The 32-bit Fletcher checksum
Parameters:
data The 16-bit data array to checksum
cnt The count of elements in data

unsigned int FCS_calculate32 ( const unsigned int *  data,
unsigned int  cnt 
)

Calculates the 32-bit Fletcher checksum over the 32-bit data array.

Returns:
The 32-bit Fletcher checksum
Parameters:
data The 32-bit data array to checksum
cnt The count of elements in data

References dprintf.

void FCS_construct ( FCS_checksum checksum  ) 

Constructs a Fletcher checksum context. This is used when the data to be checksummed is not in one contigious array.

Parameters:
checksum The Fletcher checksum context to be constructed.

References _FCS_checksum::left, _FCS_checksum::sum1, and _FCS_checksum::sum2.

unsigned int FCS_get ( const FCS_checksum checksum  ) 

Processes the Fletcher checksum context, returning the current value of the checksum.

Returns:
The current value of the 32-bit Fletcher checksum
Parameters:
checksum The Fletcher checksum context.

References _FCS_checksum::left, _FCS_checksum::sum1, and _FCS_checksum::sum2.


Generated on Thu Mar 31 11:41:39 2011 by  doxygen 1.5.8