EasyManuals Logo

YSI SonTek ADVField User Manual

YSI SonTek ADVField
228 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
Page #108 background imageLoading...
Page #108 background image
SonTek/YSI
96
ADVField Operation Manual (September 1, 2001)
A1.2.2 Checksum Calculation
The ADV uses a checksum when sending binary data over a serial port. The checksum is com-
puted with the C function
ComputeCheckSum
shown below. To understand how the checksum is
computed, assume that a sample has been placed in a segment of memory (i.e.; a character array)
in the format shown in §A1.2. The checksum is computed by the following statement in C.
CheckSum = ComputeCheckSum( buf, Sample_Length-2);
In this example,
buf
is a pointer to the memory location where the profile begins (i.e.; the name
of the character array where the profile was placed).
ComputeCheckSum
simply adds the first
Sample_Length-2
bytes starting at location
buf
, and then adds the value 0xA596. The result of
this summation is then truncated to a two-byte integer and returned. The addition of the value
0xA596 is to ensure that an all-zeros profile does not produce a valid checksum.
#define CHECK_SUM_OFFSET 0xA596
unsigned int ComputeCheckSum( unsigned char *buf, int n )
{
int i;
unsigned int ChkSum = CHECK_SUM_OFFSET;
for(i=0;i<n;i++) ChkSum += buf[i];
return(ChkSum);
}

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the YSI SonTek ADVField and is the answer not in the manual?

YSI SonTek ADVField Specifications

General IconGeneral
BrandYSI
ModelSonTek ADVField
CategoryMeasuring Instruments
LanguageEnglish

Related product manuals