jwhiddon / EDB

A re-implementation of the Arduino database library to allow more than 256 records
GNU Lesser General Public License v2.1
89 stars 43 forks source link

Examples are broken - wrong data stored/returned #36

Open sheimend opened 6 years ago

sheimend commented 6 years ago

The examples in the latest version of the EDB Arduino library (1.0.4 at the time of this writing) appear to be failing. I've tried EDB_Simple, EDB_SDCARD, and EDB_SPIFFS. The latter fails to build because the example is missing: #include <SPIFFS.h>

The other examples run, but the sample values that should be stored in the DB always return as 0, or -1 (depending on the example). For instance, here's the output from EDB_Simple:

Extended Database Library + Arduino Internal EEPROM Demo

Record Count: 0
Creating Records...
Record Count: 10
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0
ID: 0
Temp: 0

But according to the code, ID should increment up, and temperature should be ID*2.

I'm running these examples on an M5Stack, which is an ESP32 board.

I'm disappointed because I am very exited to use this library - it would be a major help for my project.

Thanks in advance for any support or bug fixes you can provide.

ianwillianb commented 5 years ago

For ESP32 use SD.open(path_file, "r+"). If you use SD.open(path_file, FILE_WRITE") it will overwrite the file after reboot. However r+ means open the file in read and write mode setting the pointer to the beginning of the file. If you use FILE_APPEND, the seek() method won't work, cause the pointer will always point to the end of the file.