
In most situations, a computer computes the signature by reading in the ASCII data and
extracting the last four ASCII characters, casting them as Long data type. The signature is then
calculated on the data sent from the CSAT3BH, starting with u
x
and ending with the counter. All
the characters after the counter are not part of the signature. Once the signature is computed
using the algorithm below, it is compared to the transmitted signature. If signatures do not
match, the data should be disregarded.
The following block of code is an example implementation of the Campbell Scientific signature
algorithm in the programming language C. To generate the signature of an output array of bytes,
the “seed” needs to be initialized to 0xaaaa and a pointer passed to the first byte of the output
array. The number of bytes in the output array should be entered in as the “swath”. The returned
value is the computed signature.
// signature(), signature algorithm.
// Standard signature is initialized with a seed of 0xaaaa.
// Returns signature.
unsigned short signature( unsigned char* buf, int swath, unsigned short seed ) {
unsigned char msb, lsb;
unsigned char b;
int i;
msb = seed >> 8;
lsb = seed;
for( i = 0; i < swath; i++ ) {
b = (lsb << 1) + msb + *buf++;
if( lsb & 0x80 ) b++;
msb = lsb;
lsb = b;
}
return (unsigned short)((msb << 8) + lsb);
}
(p. 71) shows an example of unprompted output (RS-485 or USB) to a computer.A
timestamp for the incoming data record may be assigned by the computer, where the interval
between records is 1/unprompted output rate. The data in each unprompted output record will
be delayed according to
(p. 71). Even after accounting for the sample delay, a
synchronicity error between the computer and the CSAT3BH may still exist, since they each have
their own clocks.
(p. 71) shows the possible synchronicity errors for each output rate.
CSAT3BH Three-Dimensional Heated Sonic Anemometer
70