3 of 5
• ASCII
#include <iostream.h>
#include <string.h>
void main()
{
char_*Buff_=_”BESTPOSA,COM1,0,65.5,FINESTEERING,1254,412250.000,
00000000,4ca6,34084;SOL_COMPUTED,SINGLE,51.11638281392,-
114.03823667672,1057.5312,-
16.2713,WGS84,1.7067,1.3294,2.6578,\"\",0.000,0.000,8,8,0,0,0,0,
0,0";
unsigned long iLen = strlen(Buff);
unsigned long CRC = CalculateBlockCRC32(iLen, (unsigned char*)
Buff);
cout << hex << CRC <<endl;
}
• BINARY
#include <iostream.h>
#include <string.h>
unsigned long ByteSwap (unsigned long n)
{
return (((n &0x000000FF)<<24)+(( n &0x0000FF00)<<8)+
((n &0x00FF0000)>>8)+(( n &0xFF000000)>>24));
}
void main()
{
unsigned char Buff[] = {0xAA, 0x44, 0x12, 0x1C, 0x01, 0x00,
0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00};
unsigned int iLen = sizeof Buff;
unsigned long CRC = CalculateBlockCRC32(iLen, Buff);
cout << hex << ByteSwap(CRC) <<endl;
}
** In the binary example, an optional function has been included. The purpose of this
function (“ByteSwap” ) is to reverse the byte order of the checksum. For more detail
information on the byte order, please refer the section 4, “What are Little Endian and
Big Endian?”.