Smart Features
BASLER A102
f
6-17
DRAFT
CRC Checksum Chunk Layout
The CRC checksum is an exception to the normal chunk structure. The CRC chunk is always 32
bits wide and is always the last chunk appended to the image data. The lower 16 bits of the chunk
are filled with the checksum and the upper 16 bits of the chunk are filled with zeros.
Using the Checksum to Check the Data Integrity
When the checksum smart feature is enabled, the following two C functions can be used to check
if an acquired frame contains a valid CRC checksum. The user must pass the acquired image
buffer and the buffer’s length in bytes to the CheckBuffer() function. The CheckBuffer() function
uses the CRC16() function to calculate the checksum.
These two samples are intended to aid you in developing the code for your application. They are
provided solely as examples.
/** \brief Calculates a 16 bit CRC checksum
* \param pData Pointer to the data buffer
* \param nbyLength Size of the buffer in bytes
* \return The CRC checksum
*/
unsigned short CRC16(const unsigned char *pData, unsigned long nbyLength )
{
unsigned long i, j, c, bit;
unsigned long crc = 0;
for (i=0; i<nbyLength; i++) {
c = (unsigned long)*pData++;
for (j=0x80; j; j>>=1) {
bit = crc & 0x8000;
crc <<= 1;
if (c & j) bit^= 0x8000;
if (bit) crc^= 0x1021;
}
}
return (unsigned short) (crc & 0xffff);
}
Bit
Description
[ 0 ... 7 ]
CRC Checksum low byte
[ 8 ... 15 ]
CRC Checksum high byte
[ 16 ... 23 ]
0x00
[ 24 ... 31 ]
0x00
Summary of Contents for A102f
Page 1: ...USER S MANUAL Document Number DA00063006 Release Date 7 December 2010 ...
Page 4: ......
Page 25: ...Basic Operation Standard Features BASLER A102f 3 3 DRAFT Figure 3 2 Block Diagram ...
Page 62: ...Basic Operation Standard Features 3 40 BASLER A102f DRAFT ...
Page 166: ...Mechanical Considerations 7 6 BASLER A102f DRAFT ...