Chapter 4 ________________________________________________________________ Operation
VAISALA _______________________________________________________________________ 51
The line ends with Carriage Return and Line Feed characters.
NOTE
This line is omitted if the message subclass is 5.
5TH LINE (6TH LINE OF MESSAGE NO. 2)
Example:
1a3f
♦↵
where
= End-of-Text character
1a3f
= Checksum, see below for calculation procedure
♦
= End-of-Transmission character
↵
= Carriage 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;
}