Digi ConnectPort X4 IA Quick Start Manual page 22

Hide thumbs Also See for ConnectPort X4 IA:
Table of Contents

Advertisement

Sample Response:
Existing Command Mode...
Calculating the Checksum:
The PV
-100-2 uses a 16 CRC checksum. The CRC uses the same polynomial as the
MET
one used in Xmodem transfers (XMODEM-CRC).
The Polynomial is as follows:
16
12
5
x
+ x
+ x
+ 1
The CRC calculation starts at the first ASCII character of the response. Leading carriage
return line feeds are not included. All characters are included in the calculation up until
but not including the exclamation character. The checksum is represented as a
hexadecimal number.
The following C example code can be used to calculate the checksum:
/* Global Variables */
unsigned short int acc;
/* ****************************************************************************
/* Initialize Accumulator
/* ****************************************************************************/
void
crc16Init(void)
{
acc= 0;
}
/* ****************************************************************************
/* Add byte
/* ****************************************************************************/
void
crc16Add( unsigned short int _data )
{
unsigned char n;
for (n=8; n ;n--)
{
if ((acc & 0x8000)>0)
{
acc<<= 1;
_data<<= 1;
if ((_data & 256)!=0)
acc++;
acc^= 0x1021;
}
else
{
acc<<= 1;
_data<<= 1;
if ((_data & 256)!=0)
acc++;
}
}
- 16 -

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ConnectPort X4 IA and is the answer not in the manual?

Table of Contents