Fix for CRC checking (end crc with null)

This commit is contained in:
jantenhove 2018-01-11 09:49:18 +01:00 committed by GitHub
parent 59c2102ff6
commit 452a57fa77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,8 +204,9 @@ bool decodeTelegram(int len) {
{ {
//add to crc calc //add to crc calc
currentCRC=CRC16(currentCRC,(unsigned char*)telegram+endChar, 1); currentCRC=CRC16(currentCRC,(unsigned char*)telegram+endChar, 1);
char messageCRC[4]; char messageCRC[5];
strncpy(messageCRC, telegram + endChar + 1, 4); strncpy(messageCRC, telegram + endChar + 1, 4);
messageCRC[4]=0; //thanks to HarmOtten (issue 5)
if(outputOnSerial) if(outputOnSerial)
{ {
for(int cnt=0; cnt<len;cnt++) for(int cnt=0; cnt<len;cnt++)