I am writing a library serial messaging protocol for the arduino based upon Mojobus protocol, it allows addressing and multiple commands to be sent (and therefore it is RS485 capable). It used callbacks to update device states.
One thing I would like to do is include the EEPROM.h file in my libraries .cpp file. I want to be able to store the device addresses and baud rates on restarts.
When I do an #include <EEPROM.h> i get an error:
20: error: EEPROM.h: no such file or directory In member function ...
When I include the EEPROM.h header in my .pde it works fine and no error(even though I don't use EEPROM in the .pde).
I assume the arduino environment is not recognizing the include statement in the my .cpp files and not including the necessary header and .o files for the library when it is organizing the files to compile.
/*
mojo.cpp - Library for MojoBus communication.
Created by Henry Herman, October 18, 2009.
Released under the BSD License.
*/
extern "C" {
#include <stdlib.h>
}
#include <EEPROM.h>
#include "WProgram.h"
#include "HardwareSerial.h"
...works for me. I'm using Arduino 15. Which Arduino are you using?
I did a little digging and realized the EEPROM.h library was only a light wrapper around the avr/eeprom.h library. By using the avr library I avoid the problem.
I would still like to know why it does not work in 0017....
Now I get an error as well. It appears the linker is instructed to only include libraries referenced in the PDE file.
Someone who's familiar with the IDE source code may be able to indicate if the behaviour is by design, because of a deficiency, or the result of a bug. In any case, for now, you're left with modifying the IDE source code to get the behaviour you want.
You cannot use an existing library from a new arduino lib.
The current Arduino software is designed that way. Could be changed, but would require some changes to the source-code and a new library install procedure.