jantenhove / P1-Meter-ESP8266

Software for the ESP8266 that sends P1 smart meter data to Domoticz (with CRC checking)
GNU General Public License v3.0
80 stars 38 forks source link

Bug around MessageCRC #5

Closed HarmOtten closed 6 years ago

HarmOtten commented 6 years ago

Hi Jan, I think there is a bug in your sketch. This:

    char messageCRC[4];
    strncpy(messageCRC, telegram + endChar + 1, 4);
...
    validCRCFound = (strtol(messageCRC, NULL, 16) == currentCRC);

Should be:

    char messageCRC[5];
    strncpy(messageCRC, telegram + endChar + 1, 4);
    messageCRC[4] = 0;
...
    validCRCFound = (strtol(messageCRC, NULL, 16) == currentCRC);

This will probably reduce a lot of "Invalid CRC" messages ;-)

jantenhove commented 6 years ago

Thanks. Weird. forget to commit i guess.