Code CR3600DPM Informations techniques Page 67

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 72
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 66
10/29/2014
Page 67 of 72
© 2014 The Code Corporation
12393 South Gateway Park Place Suite 600, Draper, UT 84020
(801) 495-2200
FAX (801) 495-0280
12 Appendix: Example CRC16 C Code
The CRC16 required by Reader to Host packets (see Section 5.2) can be calculated using the following
sample C code. This CRC16 consists of two consecutive bytes, each in range [0,255] most significant byte
first. A CRC16 is calculated on each packet byte, over the entire packet, excluding the prefix and the CRC16
itself.
crc_t crc = 0;
<send firstByte>
crc = crc(crc, firstByte, firstByteSize);
<send secondByte>
crc = crc(crc, secondByte, secondByteSize)
<…>
<send crcHighByte>
<send crcLowByte>
/* crc16.h */
#ifndef crc16_h
#define crc16_h
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint16_t crc_t;
crc_t crc
( crc_t initialCrc
, const unsigned char* bufPtr
, size_t length
);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
/* crc16.c */
#include <crc16.h>
Vue de la page 66
1 2 ... 62 63 64 65 66 67 68 69 70 71 72

Commentaires sur ces manuels

Pas de commentaire