GithubHelp home page GithubHelp logo

arduino-edb's People

Stargazers

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

Watchers

 avatar  avatar  avatar

arduino-edb's Issues

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.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.
I updated code to this library.
https://github.com/jwhiddon/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);
}

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

Can I query the database for an entry with a certain field?

I am trying to use this library to store a variable whenever a save button is pressed, but I also what to be able to search for these when a search is entered, is there a search function available or is it possible to make one using this library?

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

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.

Error in limit() function

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

but 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

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

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.