Pages: [1]   Go Down
Author Topic: I can't #include<EDB.h> library  (Read 792 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded EDB library from http://code.google.com/p/arduino-edb/
and I use ARDUINO IDE 1.0.3
have error compile :

Quote

In file included from RFID_EEPROM.ino:5:
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:43: error: expected initializer before '*' token
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:54: error: 'EDB_Rec' has not been declared
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:56: error: ISO C++ forbids declaration of 'EDB_Rec' with no type
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:57: error: ISO C++ forbids declaration of 'EDB_Rec' with no type
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:58: error: 'EDB_Rec' has not been declared
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:68: error: expected ',' or '...' before '*' token
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:68: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:69: error: 'byte' has not been declared
C:\Users\Admin\Desktop\arduino-1.0.3\libraries\EDB/EDB.h:72: error: ISO C++ forbids declaration of 'EDB_Rec' with no type

sorry ,this's my code, I want to create table for make database in eeprom .So I import EDB library into my code and compile it for test.

Code:



#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <EDB.h>



#define rxPin 2
#define txPin 3

char rfid_data[12];
char rfid_in[12];
int i, a, b, tmp, num;




SoftwareSerial RFID = SoftwareSerial(rxPin, txPin);

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



void setup()
{
  Serial.begin(9600);
  RFID.begin(9600);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
 
}

void loop()
{

  Serial.println("1 = Register RFID Card");
  Serial.println("2 = Remove RFID Card");
  Serial.println("3 = Delete EEPROM Database");
  Serial.println("4 = List EEPROM Database");
  Serial.println("5 = Active Mode");
  do
  {
    delay(200);
  } while (Serial.available() <= 0);
  Serial.println();
 
 
  num = Serial.read();
 
  Serial.print("Serial port Value : ");
  Serial.println(num);
 
 
  switch (num)
  {
    case '1':
      RegisterCard();
     
      break;
    case '2':
      RemoveCard();
      break;
    case '3':
      EEPROM.write(0,0);
      Serial.println("Database Erased");
      break;
    case '4':
      ListDatabase();
      break;
    case '5':
      ActiveMode();
      break;
    case '0':
      break;
    default:
      Serial.println("Unknown Input");
  }
  Serial.println();
}











void RegisterCard()
{
  // Read a card
  for (int rs = 0; rs < 13; rs++)
  {
    rfid_data[rs] = '0';
  }
  rfid_data[12] = '\0';

  digitalWrite(11, LOW);
  delay(200);
  do
  {
    delay(200);
  } while (RFID.available() <= 0);

  digitalWrite(11, HIGH);
  delay(200);
 
  Serial.println("Reading Card");
 
  rfid_data[0] = RFID.read();
  if (int(rfid_data[12]) <= 12)
  {
    for (i = 0; i < 12; i++)
    {
      rfid_data[i] = RFID.read();
    }
    rfid_data[12] = '\0';
  }

 
  RFID.flush();
  delay(500);
  /*
  digitalWrite(11, LOW);
  delay(500);
  digitalWrite(11, HIGH);
  delay(500);
  */
  Serial.print("Registering Card: ");
  Serial.println(rfid_data);
  // Check if it's in the database
  a = EEPROM.read(0);
 
  if (a == 0)
  {
    EEPROM.write(0,1);
    for (i = 1; i < 13; i++)
    {

      EEPROM.write(i,rfid_data[i-1]);
   
    }
    Serial.println("Card Registered in Database Successfully");
   
    // REMOVE START
    for (i = 0; i < 13; i++)
    {
      rfid_data[i] = '0';
    }
    rfid_data[12] = '\0';
    // REMOVE END
    return;
  }
  if (a == 100)
  {
    Serial.println("100 Cards Reached, Register Failed");
    return;
  }
 
  for (i = 0; i < a; i++)
  {
    for (b = 1; b < 13; b++)
    {
      rfid_in[b-1] = EEPROM.read((i*12)+b);
    }
    rfid_data[12] = '\0';
    b = 1;
   
    for (int c = 0; c < 12; c++)
    {
      if (rfid_data[c] == rfid_in[c])
      {
        b++;
      }
    }
    if (b == 12)
    {
      Serial.println("Card Already Exists in Database");
      return;
    }
  }
  // Add to database
  tmp = 0;
  for (int d = (a*12)+1; d < (a*12)+13; d++)
  {
    EEPROM.write(d,rfid_data[tmp]);
    tmp++;
  }
  EEPROM.write(0,a+1);
  Serial.println("Complete");
  return;
}















void ListDatabase()
{
  a = EEPROM.read(0);
  Serial.print("Cards in database: ");
  Serial.println(a);
  if (a == 0)
  {
    Serial.println("Database Empty");
    return;
  }
 
  for (i = 0; i < a; i++)
  {
    Serial.print("Card ");
    Serial.print(i);
    Serial.print(": ");
    for (b = 1; b < 13; b++)
    {
      Serial.write(EEPROM.read((i*12)+b));
    }
    Serial.println();
  }
 
  return;
}














 
void ActiveMode()
{
  // Read a card
  for (int rs = 0; rs < 13; rs++)
  {
    rfid_data[rs] = '0';
  }
  rfid_data[12] = '\0';
  digitalWrite(11, LOW);
  delay(500);
  do
  {
    delay(200);
  } while (RFID.available() <= 0);
  digitalWrite(11, HIGH);
  delay(500);
  Serial.println("Reading Card");
  rfid_data[0] = RFID.read();
  if (int(rfid_data[12]) <= 12)
  {
    for (i = 0; i < 12; i++)
    {
      rfid_data[i] = RFID.read();
    }
    rfid_data[12] = '\0';
  }
  Serial.print("Checking Card: ");
  Serial.println(rfid_data);
  // Check if it's in the database
  a = EEPROM.read(0);
  if (a == 0)
  {
    Serial.println("Access Denied!");
    RFID.flush();
    delay(1000);
    digitalWrite(11, LOW);
    delay(500);
    digitalWrite(11, HIGH);
    return;
  }
 
  for (i = 0; i < a; i++)
  {
    for (b = 1; b < 13; b++)
    {
      rfid_in[b-1] = EEPROM.read((i*12)+b);
    }
    rfid_data[12] = '\0';
    b = 1;
    for (int c = 0; c < 12; c++)
    {
      if (rfid_data[c] == rfid_in[c])
      {
        b++;
      }
    }
    if (b == 12)
    {
      Serial.println("Access Granted!");
      RFID.flush();
      delay(1000);
      digitalWrite(11, LOW);
      delay(500);
      digitalWrite(11, HIGH);
      return;
    }
  }
  Serial.println("Access Denied!");
  RFID.flush();
  delay(1000);
  digitalWrite(11, LOW);
  delay(500);
  digitalWrite(11, HIGH);
  return;
}




void RemoveCard()
{
  // Read a card
  for (int rs = 0; rs < 13; rs++)
  {
    rfid_data[rs] = '0';
  }
  rfid_data[12] = '\0';
 
 
  do
  {
    delay(200);
  } while (RFID.available() <= 0);
  digitalWrite(11, HIGH);
  delay(500);
 
  Serial.println("Reading Card");
 
  rfid_data[0] = RFID.read();
  if (int(rfid_data[12]) <= 12)
  {
    for (i = 0; i < 12; i++)
    {
      rfid_data[i] = RFID.read();
    }
    rfid_data[12] = '\0';
  }
 
  RFID.flush();
  delay(800);
  Serial.print("Removing Card: ");
  Serial.println(rfid_data);
  // Check if it's in the database
  a = EEPROM.read(0);
  if (a == 0)
  {
    Serial.println("Not in Database");
    return;
  }
 
  for (i = 0; i < a; i++)
  {
    for (b = 1; b < 13; b++)
    {
      rfid_in[b-1] = EEPROM.read((i*12)+b);
    }
    rfid_data[12] = '\0';
    b = 1;
    for (int c = 0; c < 12; c++)
    {
      if (rfid_data[c] == rfid_in[c])
      {
        b++;
      }
    }
    if (b == 12)
    {
      int rmstrt = ((i*12)+b)-11;
      // Last in database?
      if ((a*12) == (rmstrt+11))
      {
        EEPROM.write(0,a-1);
        Serial.println("Card Removed Successfully!");
        return;
      }
      for (tmp = rmstrt+12; tmp < (a*12)+1; tmp++)
      {
        char dta = EEPROM.read(tmp);
        delay(100);
        EEPROM.write(rmstrt,dta);
        rmstrt++;
      }
      delay(100);
      EEPROM.write(0,a-1);
      Serial.println("Card Removed Successfully!");
      return;
    }
  }
  Serial.println("Card Not in Database");
  return;
}


help me, please
thank you so much .
« Last Edit: February 08, 2013, 04:12:58 am by chairedevil » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where is your code?

Read this before posting a programming question
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The library at that link has not been undated for 1.0+ use. What changes did YOU make to it to make it work with 1.0.3?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks to me like you installed the library in the wrong place. You don't put stuff into the Arduino distribution folder. Read this:

http://arduino.cc/en/Guide/Libraries
Logged

Pages: [1]   Go Up
Jump to: