EasyManua.ls Logo

Nortek Signature Series - Checksum Definition

Nortek Signature Series
85 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...
Data formats 49
© 2017 Nortek AS
C-style Header Struct Definition
typedef struct
{
unsigned char sync;
unsigned char hdrSize;
unsigned char ID;
unsigned char family;
unsigned short dataSize;
unsigned short dataChecksum;
unsigned short hdrChecksum;
} CommandHeader_t;
6.1.1 Checksum Definition
The Checksum is defined as a 16-bits unsigned sum of the data (16 bits). The sum shall be
initialized to the value of 0xB58C before the checksum is calculated.
C-code for Checksum calculations:
unsigned short calculateChecksum(unsigned short *pData, unsigned
short size)
{
unsigned short checksum = 0xB58C;
unsigned short nbshorts = (size >> 1);
int i;
for (i = 0; i < nbshorts; i++)
{
checksum += *pData;
size -= 2;
pData++;
}
if (size > 0)
{
checksum += ((unsigned short)(*pData)) << 8;
}
return checksum;
}

Table of Contents

Related product manuals