Emmm ... sarò stanco e non riesco a vederlo .... ma perché diavolo questo codice da errore ???
- crc8.h :
#ifdef __cplusplus
extern "C" {
#endif
byte calc_crc8(byte *, int);
#ifdef __cplusplus
}
#endif
- crc8.c :
byte calc_crc8 (byte *data, int len)
{
byte crc = 0;
while (len--) {
byte extract = *data++;
for (byte tempI = 8; tempI; tempI--) {
byte sum = (crc ^extract) & 0x01;
crc >>= 1;
if (sum) {
crc ^= 0x8C;
}
extract >>= 1;
}
}
return (crc);
}
- il programmino di prova :
#include "crc8.h"
byte myCrc8;
void setup() {
delay(3000);
Serial.begin(9600);
myCrc8 = calc_crc8("123456789", 9);
Serial.println("Calculate CRC on string 123456789");
Serial.print("CRC8 = 0x");
Serial.println(myCrc8, HEX);
}
void loop() {
}
L'errore che ricevo :
crc8.c:1: error: expected '=', ',', ';', 'asm' or 'attribute' before 'calc_crc8'
GRAZIE
Guglielmo