EasyManua.ls Logo

Vaisala LT31 - CRC16 Checksum

Vaisala LT31
294 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...
Chapter 5 ________________________________________________________________ Operation
VAISALA ______________________________________________________________________ 155
CRC16 Checksum
The CRC16 checksum can be calculated using the following algorithm
written in the programming language C:
/* 16 bit type */
typedef unsigned short Word16;
/* Calculate CRC-16 value as used in LT31 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,
ASCII 1) character and ends after the # (End of text, ASCII 3) character.
Checksums should be used for proper operation. However, giving XXXX
(four times X [ASCII 88
DEC
/58
HEX
]) will skip checksum testing in the
LT31 system.

Table of Contents

Related product manuals