Git Product home page Git Product logo

edb's People

Contributors

4-20ma avatar davidmpye avatar jwhiddon avatar lan-hekary avatar zxpower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edb's Issues

corrupting data

other data is corrupted when i try to update 1 data.
the selected data is updated while the other is corrupted using the function updateRec

Strings in record definition

Hello,
Try as I can, I am unable to use strings within the table record definition. Is this a known limitation?
Thanks

how to change data structure of existing table

hi,
how can i change the data structure from an existing record (datamigration)

for example i have an existing structure

struct LogEvent {
int id;
int temperature;
}
logEvent;

and i have created for example 127 records with different data sets.
but now i add an new feature an have the need to migrate the old data to the new data structure for example:
struct LogEvent {
int id;
int temperature;
int newDataHere;
int andNewDataHere;
}
logEvent;

are there already edb functions available to do this task or exist an good example how to do data migration with this arduino edb?

thx in advanced
wolke

EDB open function - needs code for checking if open was OK?

I am looking in the edb lib... very interesting...!

With edb we can open a edb table from the EEPROM... How can we make sure that 
the opened edb object holds the correct data (for the corresponding record 
structure)?

I mean how can I confirm that the already opened data structure (EEPROM) and 
the EDB object (opened) use the absolute same record structure?

I even try to open a structure that was not existed (in EEPROM) and the 
function returned "EDB_OK"

I think that something is missing here...

Original issue reported on code.google.com by [email protected] on 26 Feb 2011 at 5:43

Record IDs

Hi!

I've been doing a bit more EDB related work, and have hit a small issue, which is probably more of a design issue.

EDB's record numbers start from 1, which makes sense from one angle, but is quite different logic from the usual C style arrays, which of course start from element 0.

I've made a patch which changes this behaviour and wonder whether it's the sort of thing you'd be interested in accepting upstream, or whether the current design is your preferred aesthetic :-)

Cheers

David

EDB.cpp open existing head

In ORIGINAL:
EDB_Status EDB::open(unsigned long head_ptr)
{
EDB_head_ptr = head_ptr;
// Thanks to Steve Kelly for the next line...
EDB_table_ptr = sizeof(EDB_Header) + EDB_head_ptr; // this line was originally missing in the downloaded library
readHead();
return EDB_OK;
}

CORRECT:
EDB_Status EDB::open(unsigned long head_ptr)
{
EDB_head_ptr = head_ptr;
// Thanks to Steve Kelly for the next line...
EDB_table_ptr = sizeof(EDB_Header) + EDB_head_ptr; // this line was originally missing in the downloaded library
readHead();
if (EDB_head.flag == EDB_FLAG){
return EDB_OK;
} else {
return EDB_ERROR;
}
//return EDB_OK;
}

Read db file on pc

It is possible read or see the information inside db file? how or with which program?. Thanks

Adafruit Huzzah ESP8266

Hi

I'm working with a Adafruit Huzzah ESP8266 board and I can't seem to get the EDBSimple and EDB_Internal_EEPROM examples to work. They both run on a Arduino Uno without issue. On the Huzzah they do not appear to either read or write properly (zeros are printed for both recon and temp).

Has anyone else had this problem? Any thoughts on a possible fix? Note that I have been successfully reading and writing to the EEPROM and I'm investigating EDB as a better storage approach.

Ken

I find a trivial mistake in the code of EDB_Simple.pde

EDB_Simple.pde

This code shows in your serial monitor, "Record count: 10", and 9 records are 
displayed, but last one record is lost.

To show all 10 records, this example code should be modified.

  Serial.print("Record Count: "); Serial.println(db.count());
  for (recno = 1; recno <= RECORDS_TO_CREATE; recno++)
// for (recno = 1; recno < RECORDS_TO_CREATE; recno++)

"<" should be replaced by "<=" only.

Thanks.

Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 6:02

Problem with two array of char in the struct table when disconnect and connect board

Hi!

when I try to use two char variable
and disconnect and reconnect the board does not display the variable char name2. When I use selectAll (); Shows the select name1, but not the name2. ¿ Why ? . The example function work when i use one variable char.

Thanks!

struct LogEvent {
    int id;
    int temperature;
    char name1[20];
    char name2[20];
}
logEvent;

Function to create record

void createRecords(int num_recs)
{
    Serial.print("Creating Records... ");
    for (int recno = 1; recno <= num_recs; recno++)
    {
        logEvent.id = recno;
        logEvent.temperature = random(1, 125);
        strcpy(logEvent.name1, "John");
        strcpy(logEvent.name2, "Doe");
        EDB_Status result = db.appendRec(EDB_REC logEvent);
        if (result != EDB_OK) printError(result);
    }
    Serial.println("DONE");
}

Function to Select

void selectAll()
{
    for (int recno = 1; recno <= db.count(); recno++)
    {
        EDB_Status result = db.readRec(recno, EDB_REC logEvent);
        if (result == EDB_OK)
        {
            Serial.print("Recno: ");
            Serial.print(recno);
            Serial.print(" ID: ");
            Serial.print(logEvent.id);
            Serial.print(" Temp: ");
            Serial.print(logEvent.temperature);
            Serial.print(" Name 1: ");
            Serial.print(logEvent.name1);
            Serial.print(" Name 2: ");
            Serial.println(logEvent.name2);
        }
        else printError(result);
    }
}

When I do not disconnect image 1
When i disconnect image 2

db.open() not working?

I've managed to create a database (which shows up as a file on my SD card), but my program doesn't get past the line EDB_Status result = db.open(0);. Any idea what could be going wrong? Below my code (using an UNO):

#include <SPI.h>
#include <SD.h>
#define SD_PIN 10  //SD read/write pin
#define TABLE_SIZE 8192  //256*32
#include "Arduino.h"
#include <EDB.h>

char* db_name = "/DB/SENSOR.DB";
File dbFile;

struct sensorLog {
  unsigned int id;
  float input;
  unsigned int timestamp;    
} 
sensorLog;

// Setting up EDB object
inline void writer (unsigned long address, const byte* data, unsigned int recsize) {
  dbFile.seek(address);
  dbFile.write(data,recsize);
  dbFile.flush();
}
inline void reader (unsigned long address, byte* data, unsigned int recsize) {
  dbFile.seek(address);
  dbFile.read(data,recsize);
}
// Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);


void setup() {

  Serial.begin(57600);

  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_PIN)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  // create file
  dbFile = SD.open(db_name, FILE_WRITE);
  db.create(0, TABLE_SIZE, (unsigned int)sizeof(sensorLog));
  dbFile.close();

  // open file
  dbFile = SD.open(db_name, FILE_WRITE);
  if (!dbFile) { Serial.println("File does not exist"); }
  if (dbFile) { 
    Serial.println("File exists!");  // returns "File exists!"
    EDB_Status result = db.open(0);
    Serial.println("Result: " + String(result));  // is not printed
    if (result == EDB_OK) {
        Serial.println("DONE");
    } else {
        Serial.println("ERROR: Did not find database in the file " + String(db_name));
    }
  }

  // code to do stuff, if the above would work...

  // close file
  dbFile.close();

}

void loop() {

}

ESP32 SPIFFS incredibly slow?

I just tested the SPIFFS example on an ESP32 in platformio.
I made the following changes:

  • add function declarations before setup() (required by compiler)
  • change serial speed to 115200
    Then the example ran without further changes. But I was surprised to see that the insert operations take several seconds (!) with the unchanged TABLE_SIZE 8192 and a record count of 34 (after adding the new ones).
    I added esp_timer_get_time() (=uptime in µs) to the insertOneRecord function and got this output, see the 20th insert took about 3 full seconds.
    Is this normal/expected? I would not have expected more than a few ms even for a "slow" operation of this magnitude.
Creating table... DONE
Record Limit: 1022
Record Count: 0
Creating Records... DONE
Record Count: 10
Recno: 1 ID: 1 Temp: 55
Recno: 2 ID: 2 Temp: 116
Recno: 3 ID: 3 Temp: 113
Recno: 4 ID: 4 Temp: 66
Recno: 5 ID: 5 Temp: 78
Recno: 6 ID: 6 Temp: 32
Recno: 7 ID: 7 Temp: 57
Recno: 8 ID: 8 Temp: 94
Recno: 9 ID: 9 Temp: 42
Recno: 10 ID: 10 Temp: 32
Deleting recno: 5
Record Count: 9
Recno: 1 ID: 1 Temp: 55
Recno: 2 ID: 2 Temp: 116
Recno: 3 ID: 3 Temp: 113
Recno: 4 ID: 4 Temp: 66
Recno: 5 ID: 6 Temp: 32
Recno: 6 ID: 7 Temp: 57
Recno: 7 ID: 8 Temp: 94
Recno: 8 ID: 9 Temp: 42
Recno: 9 ID: 10 Temp: 32
Appending record... DONE
Record Count: 10
Recno: 1 ID: 1 Temp: 55
Recno: 2 ID: 2 Temp: 116
Recno: 3 ID: 3 Temp: 113
Recno: 4 ID: 4 Temp: 66
Recno: 5 ID: 6 Temp: 32
Recno: 6 ID: 7 Temp: 57
Recno: 7 ID: 8 Temp: 94
Recno: 8 ID: 9 Temp: 42
Recno: 9 ID: 10 Temp: 32
Recno: 10 ID: 11 Temp: 68
6681740 Inserting record at recno: 5...
7775880 DONE
Record Count: 11
Recno: 1 ID: 1 Temp: 55
Recno: 2 ID: 2 Temp: 116
Recno: 3 ID: 3 Temp: 113
Recno: 4 ID: 4 Temp: 66
Recno: 5 ID: 5 Temp: 69
Recno: 6 ID: 6 Temp: 32
Recno: 7 ID: 7 Temp: 57
Recno: 8 ID: 8 Temp: 94
Recno: 9 ID: 9 Temp: 42
Recno: 10 ID: 10 Temp: 32
Recno: 11 ID: 11 Temp: 68
Updating record at recno: 10... DONE
Recno: 1 ID: 1 Temp: 55
Recno: 2 ID: 2 Temp: 116
Recno: 3 ID: 3 Temp: 113
Recno: 4 ID: 4 Temp: 66
Recno: 5 ID: 5 Temp: 69
Recno: 6 ID: 6 Temp: 32
Recno: 7 ID: 7 Temp: 57
Recno: 8 ID: 8 Temp: 94
Recno: 9 ID: 9 Temp: 42
Recno: 10 ID: 1234 Temp: 4321
Recno: 11 ID: 11 Temp: 68
Record Count: 11
Truncating table... DONE
Use insertRec() and deleteRec() carefully, they can be slow
Record Count: 0
8158189 Inserting record at recno: 1...
8499716 DONE
8499863 Inserting record at recno: 1...
9065511 DONE
9065680 Inserting record at recno: 1...
9675683 DONE
9675860 Inserting record at recno: 1...
10381244 DONE
10381413 Inserting record at recno: 1...
11382561 DONE
11382731 Inserting record at recno: 1...
12412779 DONE
12412955 Inserting record at recno: 1...
13678041 DONE
13678211 Inserting record at recno: 1...
15048959 DONE
15049129 Inserting record at recno: 1...
16455694 DONE
16455872 Inserting record at recno: 1...
18087719 DONE
18087896 Inserting record at recno: 1...
19854274 DONE
19854444 Inserting record at recno: 1...
21619922 DONE
21620091 Inserting record at recno: 1...
23594314 DONE
23594484 Inserting record at recno: 1...
25602773 DONE
25602947 Inserting record at recno: 1...
27833130 DONE
27833300 Inserting record at recno: 1...
30171755 DONE
30171933 Inserting record at recno: 1...
32538511 DONE
32538681 Inserting record at recno: 1...
35130074 DONE
35130244 Inserting record at recno: 1...
37841720 DONE
37841896 Inserting record at recno: 1...
40969952 DONE
Record Count: 20
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Deleting recno: 1
Record Count: 0

do not use EDB.h for multiple databases

For implement multiple databases, we have to use this code:

db.create(1, (unsigned int)sizeof(EDB_Header) + TABLE_SIZE, (unsigned int)sizeof(secondStruct));

but now, the count() method return all count of tables records not my table record count, also for select data from my table, there is no any idea because we using same count() method.

What do you suggest?
Good Luck.

May I partially update Struct?

For example

struct BlackList {
char sessioncard_dbb[10];
int id_local;
int cardblocked;
}
blackList;

and i want to update just cardblocked.

blackList.cardblocked = cardchangeto1;
EDB_Status result = db1.updateRec(numbc1, EDB_REC blackList);

But after that the rest of struct becomes zeroes.

I need to read the struct to variables and update in whole?

thanks!

Error in open()

EDB_table_ptr should be updated in open()

// reads an existing edb header at a given recno and sets header values
EDB_Status EDB::open(unsigned long head_ptr)
{
  EDB_head_ptr = head_ptr;
  EDB_table_ptr = sizeof(EDB_Header) + EDB_head_ptr; // <<--- add this
  readHead();
  return EDB_OK;
}

Original issue reported on code.google.com by [email protected] on 4 Jul 2015 at 10:11

Error when loading data after reset

What steps will reproduce the problem?

I modified the sample code somewhat to show what I was getting in my 
own sketch.  Below is the updated sample.

/*
 EDB_Simple.pde
 Extended Database Library + Internal Arduino EEPROM Demo Sketch

 The Extended Database library project page is here:

 */
#include "WProgram.h"
#include <EDB.h>

// Use the Internal Arduino EEPROM as storage
#include <EEPROM.h>

// Uncomment the line appropriate for your platform
#define TABLE_SIZE 512 // Arduino 168 or greater

// The number of demo records that should be created.  This should be 
less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is 
higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the 
usable range.
#define RECORDS_TO_CREATE 10

// Arbitrary record definition for this table.  
// This should be modified to reflect your record needs.
struct LogEvent {
  char something[50];
  char something2[8];
  int id;
  int temperature;
}
logEvent;

// The read and write handlers for using the EEPROM Library
void writer(unsigned long address, byte data)
{
  EEPROM.write(address, data);
}

byte reader(unsigned long address)
{
  return EEPROM.read(address);
}

// Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);

void setup()
{
  Serial.begin(9600);
  Serial.println("Extended Database Library + Arduino Internal EEPROM 
Demo");
  Serial.println();

  //db.create(0, TABLE_SIZE, sizeof(logEvent));
  db.open(0);
  Serial.print("Record Count: "); Serial.println(db.count());

  Serial.println("Creating Records...");
  int recno;

  Serial.print("Record Count: "); Serial.println(db.count());
  for (recno = 1; recno < RECORDS_TO_CREATE; recno++)
  {
    db.readRec(recno, EDB_REC logEvent);
    Serial.print("ID: "); Serial.println(logEvent.id);
    Serial.print("Temp: "); Serial.println(logEvent.temperature);  
    Serial.print("1: "); Serial.println(logEvent.something);
    Serial.print("2: "); Serial.println(logEvent.something2);  
  }
  db.clear();
  db.create(0, TABLE_SIZE, sizeof(logEvent));
  for (recno = 1; recno <= RECORDS_TO_CREATE; recno++)
  {
    logEvent.id = recno;
    logEvent.temperature = recno * 2;
    strcpy(logEvent.something, "some test data that is long");
    strcpy(logEvent.something2, "test2");
    db.appendRec(EDB_REC logEvent);
  }
  Serial.print("Record Count: "); Serial.println(db.count());
  for (recno = 1; recno < RECORDS_TO_CREATE; recno++)
  {
    db.readRec(recno, EDB_REC logEvent);
    Serial.print("ID: "); Serial.println(logEvent.id);
    Serial.print("Temp: "); Serial.println(logEvent.temperature);  
    Serial.print("1: "); Serial.println(logEvent.something);
    Serial.print("2: "); Serial.println(logEvent.something2);  
  }
}

void loop()
{
}


What is the expected output? What do you see instead?

Output for the first run:

Extended Database Library + Arduino Internal EEPROM Demo

Record Count: 0
Creating Records...
Record Count: 0
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
ID: 0
Temp: 0
1:
2:
Record Count: 8
ID: 1
Temp: 2
1: some test data that is long
2: test2
ID: 2
Temp: 4
1: some test data that is long
2: test2
ID: 3
Temp: 6
1: some test data that is long
2: test2
ID: 4
Temp: 8
1: some test data that is long
2: test2
ID: 5
Temp: 10
1: some test data that is long
2: test2
ID: 6
Temp: 12
1: some test data that is long
2: test2
ID: 7
Temp: 14
1: some test data that is long
2: test2
ID: 8
Temp: 16
1: some test data that is long
2: test2
ID: 8
Temp: 16
1: some test data that is long
2: test2

Output after the Reset is pressed.

Extended Database Library + Arduino Internal EEPROM Demo

Record Count: 8
Creating Records...
Record Count: 8
ID: 0
Temp: 25972
1:
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
ID: 0
Temp: 25972
1: st2
2:
Record Count: 8
ID: 1
Temp: 2
1: some test data that is long
2: test2
ID: 2
Temp: 4
1: some test data that is long
2: test2
ID: 3
Temp: 6
1: some test data that is long
2: test2
ID: 4
Temp: 8
1: some test data that is long
2: test2
ID: 5
Temp: 10
1: some test data that is long
2: test2
ID: 6
Temp: 12
1: some test data that is long
2: test2
ID: 7
Temp: 14
1: some test data that is long
2: test2
ID: 8
Temp: 16
1: some test data that is long
2: test2
ID: 8
Temp: 16
1: some test data that is long
2: test2

What version of the product are you using? On what operating system?

I am on an at328 with 1k EEPROM.



Original issue reported on code.google.com by [email protected] on 20 Mar 2010 at 9:52

db.count error when using multiple tables

Hi!

I have a issue when i try to use multiple tables. A just created table don't retrieve zero when call count function.

Follow a example of output:

#define TABLE_SIZE 8192
#define TABLE_1 0
#define TABLE_2 1
#define TABLE_3 2
#define TABLE_4 3

enum Enum1
{
    OPT1,
    OPT2
};

enum Enum2
{
    OPT1,
    OPT2
};

enum Enum3
{
    OPT1,
    OPT2
};

struct  Struct1
{
    uint8_t field1;
    Enum1 field2;
};

struct Struct2
{
    int id;
    char* field1;
    tmElements_t field2;
    tmElements_t field3;
    int field4;
    int field5;
    int field6;
    Enum2 field7;
    Enum2 field8;
};

struct Struct3
{
    Enum3 field1;
};

struct Struct4
{
    int field1;
    tmElements_t field2;
    tmElements_t field3;
    int field4;
};

void Test() {
    db.create(TABLE_1, TABLE_SIZE, sizeof(Struct1));
    db.create(TABLE_2, TABLE_SIZE, sizeof(Struct4));
    db.create(TABLE_3, TABLE_SIZE, sizeof(Struct2));
    db.create(TABLE_4, TABLE_SIZE, sizeof(Struct3));

    db.open(TABLE_1);
    Serial.println(_db.count()); >> 0

    db.open(TABLE_2);
    Serial.println(_db.count()); >> 301989888

    db.open(TABLE_3);
    Serial.println(_db.count()); >> 1179648

    db.open(TABLE_4);
    Serial.println(_db.count()); >> 4608
}

How can i proceed?

Error in limit() function

unsigned long EDB::limit()
{
   return (EDB_head.table_size - EDB_table_ptr) / EDB_head.rec_size;
}

and should be

unsigned long EDB::limit()
{
   return (EDB_head.table_size - sizeof(EDB_Header)) / EDB_head.rec_size;
}

Original issue reported on code.google.com by [email protected] on 4 Jul 2015 at 8:31

Examples are broken - wrong data stored/returned

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.

blockwise write in SPIFFS to speed things up

Testing the library I found that it is VERY slow when writing bigger structs to the database. I have a struct size of about 40 bytes and writing one entry takes about 500ms (!) to write one entry to the SPIFFS file system.
Now if I change your source code so that instead of writing each byte separately it writes out the whole struct in one go by passing the pointer and the struct size to the external write function and using
DBfile.write(data,datasize);
to write the whole block at once it speeds up significantly, like 30x.
Now it takes just 10 seconds to write the whole database with 500 entries instead of a few minutes and to search for a integer value it now takes 25ms instead of 900ms.
I tried to modify the original code with overloaded writing functions but my knowledge in c++ is not good enough to make it work so it is still compatible with the current version.
can you add this functionality?
edit:
I commited my changes to the code here:
87f312c

The handler functions look like this:

File userDBfile; //user database file resides in SPIFFS

void userDBwriter (unsigned long address, const uint8_t* data, unsigned int datasize) {
  userDBfile.seek(address, fs::SeekSet);
  userDBfile.write(data,datasize);
  userDBfile.flush();
}

void userDBreader (unsigned long address, uint8_t* data, unsigned int datasize) {
  userDBfile.seek(address, fs::SeekSet);
  userDBfile.read(data, datasize);
}
`

To have multiple databases

To have multiple databases for different data structures, we must control the start address of each one of them.

¿How calculate start address for each "database"?

Regards.

Warning C++ forbids converting a string constant to 'char* building SPIFFS demo

Total noob here, am getting a warning building the Extended Database Library + SPIFFS Flash FS Demo. The build does complete successfully, am wondering if there is any reason to expect issues with the db as a result?

C:/Users/ME/Documents/PlatformIO/Projects/Database/src/main.ino:51:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Line 51: EDB db(&writer, &reader);

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = Arduino

Thank you!

WDT resets with EDB_SPIFFS example

I am using the EDB_SPIFFS example with a ESP8266 generic module (Arduino IDE 1.6.8, ESP8266 core 2.3.0, EDB 1.0.3), and it's calling WDT reset because no have delay(); in the code.

I put some delay(); and it resets less frequently, but it-s not very stable...

Has anyone had a similar problem?

MMC card

Hi,
Could you give me an example for using SD card as data location? I'm using Arduino Ethernet Shield R.3 as SD card reader. thanks

db.open() function returns Zero

I want to create table only once in life time. I am using this function to detect if table exists or not. But this function always returns me 0(Zero) every time even if table exists or not.
get this updated open() function from here..
https://github.com/firebull/arduino-edb/blob/master/EDB.cpp

EDB_Status result = db.open(0);
if (result == EDB_ERROR) {
        Serial.println("Creating DB " + String(0));
        db.create(0, TABLE_SIZE, sizeof(LogEvent));

}
else{
Serial.println(result);
}

Always asking me for a SQLCipher

When I try to create or modify a.db file from sd, I always need to type in a SQLCipher Key to open the database on the PC again.

How to make the library work for SD card usage is by doing the following:

The Fix

For Arduino (Uno/Mega etc.)

Replace all instances of:
dbFile = SD.open(db_name, FILE_WRITE);
With:
dbFile = SD.open(db_name, O_READ | O_WRITE | O_CREAT);

For ESP32 etc.

Include the FS.h file: #include <FS.h>

Where the database file is first created:
Change dbFile = SD.open(db_name, FILE_WRITE); to dbFile = SD.open(db_name, "w+");

Where an existing database file is opened:
Change dbFile = SD.open(db_name, FILE_WRITE); to dbFile = SD.open(db_name, "r+");

Test with the SD card example to verify that the fix works for you. The temperature values should only be between 1 and 125, not very large or negative numbers.

Explaination

Currently the file.seek() functionality in the Arduino standard SD Library does not work properly with EDB due to the O_APPEND flag when opening a file. Apparently O_APPEND forces the file.write() to always be at last position even if you use the file.seek() function to move the "cursor" around. FILE_WRITE is defined as (O_READ | O_WRITE | O_CREAT | O_APPEND). So, to work with file.seek() without problem, you could open file with every clause except O_APPEND.
(see: here)

A second solution for Arduino is to use the SdFat library. Install SdFat through the Library Manager, then add SdFat SD; after including SdFat: #include <SdFat.h>. Make sure to comment out or remove #include <SD.h>. The rest of the code remains the same.

For the ESP32, it uses a posix compliant file.open() functionality, such that "w+" and "r+" can be supplied as modes of opening files. (see here and here)

Hope this helps.

How do use with SD card?

What steps will reproduce the problem?
1. How do you use this with and SD card?
2. You can change the position in the SD file by the position but that does not 
read or write.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 30 Dec 2013 at 9:39

Read bug in Example EDB_SDCARD_Optimized.ino

Running selectAll() function returns the last record inserted for all reads. I tested printing the address that is being read and it's correct. I even modified the struct to hold strings, and the data generation in createRecords() to create it in string form also, to check for the data on my computer. The data is all on the SD, but reading from the table still only returns the last value inserted even for a selectAll().

I'm working on an Sparkfun ESP32 Thing. I tested if SD readings were correct by running the SD lib examples and they work fine.

Any help in how to debug is much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.