01.06.2013 Views

SonTek/YSI Argonaut-XR Technical Manual - HydroScientific West

SonTek/YSI Argonaut-XR Technical Manual - HydroScientific West

SonTek/YSI Argonaut-XR Technical Manual - HydroScientific West

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A1.4. Checksum Calculation<br />

<strong>Argonaut</strong> Operation <strong>Manual</strong> Firmware Version 7.9 (May 1, 2001)<br />

<strong>SonTek</strong>/<strong>YSI</strong><br />

The <strong>Argonaut</strong> uses a checksum with each sample and whenever transmitting binary data over a<br />

serial port. The checksum is computed with the C function "ComputeCheckSum" included<br />

below. To understand how the checksum is computed, assume that a sample has been placed in a<br />

segment of memory (i.e., a character array). The checksum value is stored as the last byte in this<br />

array. The checksum is computed by the following C program statement.<br />

CheckSum = ComputeCheckSum( buffer, Sample_Length - 1 );<br />

In this statement, "buffer" is a pointer to the memory location where the sample begins (i.e., the<br />

name of the character array where the sample was placed). "ComputeCheckSum" adds the first<br />

"Sample_Length - 1" bytes starting at location buffer, then adds the value 0xA596. The result of<br />

this summation is truncated to one (unsigned) byte and returned. The addition of the value<br />

0xA596 is done so that an all-zeros sample does not produce a valid checksum.<br />

#define CHECK_SUM_OFFSET 0xA596<br />

unsigned int ComputeCheckSum( unsigned char *buf, int n )<br />

{<br />

int i;<br />

unsigned int ChkSum = CHECK_SUM_OFFSET;<br />

for(i=0;i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!