Welch-allyn SureTemp PlusModule - User Manual Instrukcja Użytkownika Strona 37

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 85
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 36
SureTemp Plus Module OEM Implementation Communications Protocol
Welch Allyn OEM Technologies Confidential 37
Checksum Calculation
The checksum is a single-byte summation of all the data, including the control characters
(preamble, command, type, byte count, data, and so on).
After computing the checksum, send the negative of the checksum.
When receiving a message, sum all of the characters (including the checksum) into an unsigned
8-bit variable. The resulting summation must be zero, since the checksum equals the negative
value of all the bytes (excluding the checksum).
The following code sample sends bytes over the link:
extern void response(unsigned short size, const void *data)
{
unsigned char cksum;
unsigned char *ptr, c;
/* Initialize checksum */
ptr = (unsigned char*) data;
cksum=0;
while (size- -)
{
c = *ptr;
put_byte(c); /* Send data byte */
cksum += c; /* Update checksum */
ptr++; /* Bump pointer to next byte to send */
}
put_byte(-cksum); /* Send the negative of the checksum */
}
Przeglądanie stron 36
1 2 ... 32 33 34 35 36 37 38 39 40 41 42 ... 84 85

Komentarze do niniejszej Instrukcji

Brak uwag