EasyManua.ls Logo

Vaisala CL31 - CRC16 Checksum

Vaisala CL31
142 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_______________________________________________________________________ 69
NOTE
The next line is omitted if the message subclass is 5.
5TH LINE (6TH LINE IN MESSAGE NO. 2)
Example: 1a3f
where
= End-of-Text character
1a3f = Checksum, see below for calculation procedure
= End-of-Transmission character
= Carriage Return + Line Feed
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 CL31. */
Word16 crc16(const unsigned char *buf, int len)
{
Word16 crc;
Word16 xmask;
int i, j;
crc = 0xffff;
for (i = 0; i < len; ++i)
{
crc ^= buf[i] << 8;
for (j = 0; j < 8; ++j)
{
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-Text character, that is, the first
character included is C and the last one included is End-of-Text.

Table of Contents

Related product manuals