Hello
I have a function that computes an CRC code using this code
byte dataBusOut[5]= {0x01,0x7b,0x7f,0x00,0x04};//start byte , ID, message, CRC ,End Byte --max usable values
byte checkCrc( byte startByte, byte id, byte message , byte endByte)
{
Serial.println(startByte,HEX);//To test the element
Serial.println(id,HEX);//To test the element
Serial.println(message,HEX);//To test the element
Serial.println(endByte,HEX);//Bad element sometimes
byte crcCalc = startByte +id + message + endByte;
return crcCalc;
}
This code works but what is bugging me is the array elements.I just need 5 elements to put data but if I declared the array byte dataBusOut[4] which will have space for 5 elements the last element gets changed somehow causing the CRC to get diferent values from the same data.If I declare it byte dataBusOut[5] it works well.
what I am missing here