code:
char pol = 0x91;
char u = 0;
char j = 0;
char CRC = 0;
char crc;
int Length;
char cmd[] = {0x7E, 0x09, 0x03, 0x05, 0x01, 0x40, 0xFF, 0x00, 0x7E} ; // [H,L,D,S,Com,D.comm,Auth,CRC,T]
char Getcrc (cmd, Length)
{
if ( j == Length )
{
cmd[7] = CRC;
}
else
{
for ( j = 0; j < Length; j++)
{
CRC = CRC ^ cmd[j]
if (u == 8)
{
j = j + 1
}
else
{
crc = CRC & 1;
if (crc == 1)
{
for (u = 0; u < 8; u++)
{
CRC = CRC ^ pol;
CRC = CRC >> 1;
}
}
else
{
CRC = CRC >> 1;
}
}
}
}
}
void setup() {
Getcrc(&cmd[1], 6);
Serial.print("The CRC of the data is :" , CRC);
}
void loop() {
}
===========================================================
it gives me the following
CRC.ino:2:14: error: 'cmd' was not declared in this scope
CRC.ino:2:19: error: 'Length' was not declared in this scope
CRC.ino:2:25: error: expression list treated as compound expression in initializer [-fpermissive]
CRC.ino:9:14: error: redefinition of 'char Getcrc'
CRC.ino:2:6: error: 'char Getcrc' previously defined here
'cmd' was not declared in this scope
CRC.ino (779 Bytes)