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++)
{
ch= *pData;
size -= 2;
pData++;
}
if (size > 0)
{
ch= ((unsigned short)(*pData)) << 8;
}
return checksum;
}
Содержание Signature 100
Страница 1: ......