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

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

Open darkpipo6 opened 7 years ago

darkpipo6 commented 7 years ago

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