EasyManua.ls Logo

Vaisala FS11P - CRC16 Checksum

Vaisala FS11P
232 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
User's Guide _______________________________________________________________________
222 __________________________________________________________________ M211107EN-C
CRC16 Checksum
The CRC16 checksum can be calculated using the following algorithm
written in the C programming language:
/* 16 bit type */
typedef unsigned short Word16;
/* Calculate CRC-16 value as used in FS11P protocol */
Word16 crc16(const unsigned char *buf, int len) {
Word16 crc;
int i,j;
crc=0xffff;
for (i=0;i<len;++i) {
crc^=buf[i]<<8;
for (j=0;j<8;++j) {
Word16 xmask=(crc&0x8000)?0x1021:0;
crc<<=1;
crc^=xmask;
}
}
return crc^0xffff;
}
The calculation of the checksum starts after the
!
(start of heading)
character and ends after the
#
(end of transmission) character.

Table of Contents

Related product manuals