-
-
Notifications
You must be signed in to change notification settings - Fork 29
Description
I've tried using this function in a program which makes repetitive writes to the EEPROM, but wanted to avoid the additional work to see if the write is actually necessary. I'm assuming this function is designed to write blocks that have only changed and return the bytes that were in the end written. However when I use the function it kept writing (or appeared to) even though the data on the EEPROM and buffer were the same.
I realized you are incrementing 'bytes' (return value) from outside memcmp{} block in updateBlock(), therefore always returning full buffer size, not just what was written
bytes += _ReadBlock(address, buf, count);
if (memcmp(buffer, buf, count) != 0) {
_pageBlock(address, buffer, count, true);
}But I believe you meant to do... Hopefully I'm getting this correct. Just an FYI -
haven't check the other update function updateByte()?
_ReadBlock(address, buf, count);
if (memcmp(buffer, buf, count) != 0) {
_pageBlock(address, buffer, count, true);
bytes += count;
}(updated for syntax highlighting)