Closed geologic closed 6 years ago
The buffer is circular, the read address could be before or after the write address and additionally there may be gaps.
Read the comments here
https://github.com/sleemanj/DS3231_Simple/blob/master/DS3231_Simple.h#L355
to implement a count, study https://github.com/sleemanj/DS3231_Simple/blob/master/DS3231_Simple.cpp#L162 and see how it works, it reads all the log entries, so you can do the same thing and instead of looking for the oldest, keep a count.
On 2018-05-13 23:23, geologic wrote:
Hi
I need to count the number of log entries before call readlog(), so i exposed findEEPROMReadAddress() and findEEPROMWriteAddress() (moved them from protected to public on the library). I use this code to get the number of logs:
uint16_t start=Clock.findEEPROMReadAddress(); uint16_t end=Clock.findEEPROMWriteAddress(); int size=end-start; //size of log in bytes When i print size, it gives me odd values. I tested writing 2 log entries of 12 bytes each (including timestamp) and the output is 2424 (should be 24). If i write 5 log entries the output is 6060 (should be 60). It seems that Clock.findEEPROMWriteAddress() reports some kind of shifting...
Im i doing something wrong?
-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].
[1] https://github.com/sleemanj/DS3231_Simple/issues/12 [2] https://github.com/notifications/unsubscribe-auth/AAMpaQ-1cNLFqqkS424Yq6Jg95cWlptOks5tyBewgaJpZM4T8wq2
Thanks. I cloned findEEPROMReadAddress() and changed like you suggested to return the number of logs.
Hi
I need to count the number of log entries before call readlog(), so i exposed findEEPROMReadAddress() and findEEPROMWriteAddress() (moved them from protected to public on the library). I use this code to get the number of logs:
uint16_t start=Clock.findEEPROMReadAddress(); uint16_t end=Clock.findEEPROMWriteAddress(); int size=end-start; //size of log in bytes
When i print size, it gives me odd values. I tested writing 2 log entries of 12 bytes each (including timestamp) and the output is 2424 (should be 24). If i write 5 log entries the output is 6060 (should be 60). It seems that Clock.findEEPROMWriteAddress() reports some kind of shifting...Im i doing something wrong?