32-Bit Crc - Novatel GPStation-6 User Manual

Gnss ionospheric scintillation and tec monitor (gistm) receiver
Table of Contents

Advertisement

3.4.4

32-Bit CRC

The ASCII and Binary OEM6 family message formats all contain a 32-bit CRC for data verification.
This allows the user to ensure the data received (or transmitted) is valid with a high level of certainty.
This CRC can be generated using the following C algorithm:
#define CRC32_POLYNOMIAL
/* --------------------------------------------------------------------------
Calculate a CRC value to be used by CRC calculation functions.
-------------------------------------------------------------------------- */
unsigned long CRC32Value(int i)
{
int j;
unsigned long ulCRC;
ulCRC = i;
for ( j = 8 ; j > 0; j-- )
{
if ( ulCRC & 1 )
else
}
return ulCRC;
}
/* --------------------------------------------------------------------------
Calculates the CRC-32 of a block of data all at once
-------------------------------------------------------------------------- */
unsigned long CalculateBlockCRC32(
unsigned long ulCount,
unsigned char *ucBuffer ) /* Data block */
{
unsigned long ulTemp1;
unsigned long ulTemp2;
unsigned long ulCRC = 0;
while ( ulCount-- != 0 )
{
ulTemp1 = ( ulCRC >> 8 ) & 0x00FFFFFFL;
ulTemp2 = CRC32Value( ((int) ulCRC ^ *ucBuffer++ ) & 0xff );
ulCRC = ulTemp1 ^ ulTemp2;
}
return( ulCRC );
}
43
0xEDB88320L
ulCRC = ( ulCRC >> 1 ) ^ CRC32_POLYNOMIAL;
ulCRC >>= 1;
/* Number of bytes in the data block */
GPStation-6 User Manual Rev 2
Messages

Advertisement

Table of Contents
loading

Table of Contents