I am fairly new to programming the Uno and need help with getting SdFat to link. I am using IDE 1.0.6 on a Debian Wheezy box. I followed the instructions at http://arduino.cc/en/Guide/Libraries I downloaded SdFat.zip and installed it through 1.0.6->Sketch->Import Library... SdFat was installed in my sketchbook/libraries/SdFat directory and the SdFat library appears in the Sketch->Import Library menu.
I see ~/sketchbook/libraries/SdFat when I echo $LD_LIBRARY_PATH
However, I can not get any of my sketches to link to the SdFar libraries. I can link to the SD libraries fine.
Thank you for your response, sorry to take so long to get back to you response.
Listing of example sketch SdFatRewrite:
/*
Rewrite Example
This sketch shows how to rewrite part of a line in the middle
of the file created by the SdFatAppend.pde example.
Check around line 30 of pass 50 of APPEND.TXT after running this sketch.
*/ #include <SdFat.h> #include <SdFatUtil.h> // use functions to print strings from flash memory
// store error strings in flash to save RAM #define error(s) error_P(PSTR(s))
void error_P(const char *str)
{
PgmPrint("error: ");
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
while(1);
}
void setup(void)
{
Serial.begin(9600);
Serial.println();
PgmPrintln("Type any character to start");
while (!Serial.available());
// initialize the SD card
if (!card.init()) error("card.init");
// initialize a FAT volume
if (!volume.init(card)) error("volume.init");
// open the root directory
if (!root.openRoot(volume)) error("openRoot");
char name[] = "APPEND.TXT";
// open for read and write
if (!file.open(root, name, O_RDWR)) {
PgmPrint("Can't open ");
Serial.println(name);
PgmPrintln("Run the append example to create the file.");
error("file.open");
}
// seek to middle of file
if (!file.seekSet(file.fileSize()/2)) error("file.seekSet");
// find end of line
int16_t c;
while ((c = file.read()) > 0 && c != '\n');
if (c < 0) error("file.read");
// clear write error flag
file.writeError = false;
// rewrite the begining of the line at the current position
file.write("rewrite");
if (file.writeError) error("file.write");
if (!file.close()) error("file.close");
Serial.print(name);
PgmPrintln(" rewrite done.");
}
void loop(void) {}
errors:
Arduino: 1.0.6 (Linux), Board: "Arduino Mega 2560 or Mega ADK"
/home/otrcomm/downloads/arduino-ide/arduino-1.0.6/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/home/otrcomm/downloads/arduino-ide/arduino-1.0.6/hardware/arduino/cores/arduino -I/home/otrcomm/downloads/arduino-ide/arduino-1.0.6/hardware/arduino/variants/mega -I/home/otrcomm/sketchbook/libraries/SdFat /tmp/build6496159611916882408.tmp/SdFatRewrite.cpp -o /tmp/build6496159611916882408.tmp/SdFatRewrite.cpp.o
In file included from /home/otrcomm/sketchbook/libraries/SdFat/SdFat.h:30,
from SdFatRewrite.pde:9:
/home/otrcomm/sketchbook/libraries/SdFat/Sd2Card.h:39:22: warning: extra tokens at end of #ifdef directive
In file included from SdFatRewrite.pde:10:
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h:27:22: warning: WProgram.h: No such file or directory
In file included from SdFatRewrite.pde:9:
/home/otrcomm/sketchbook/libraries/SdFat/SdFat.h:294: error: conflicting return type specified for ‘virtual void SdFile::write(uint8_t)’
/home/otrcomm/downloads/arduino-ide/arduino-1.0.6/hardware/arduino/cores/arduino/Print.h:48: error: overriding ‘virtual size_t Print::write(uint8_t)’
In file included from SdFatRewrite.pde:10:
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h: In function ‘void SerialPrint_P(const prog_char*)’:
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h:60: error: ‘Serial’ was not declared in this scope
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h: In function ‘void SerialPrintln_P(const prog_char*)’:
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h:71: error: ‘Serial’ was not declared in this scope
SdFatRewrite.pde: In function ‘void error_P(const char*)’:
SdFatRewrite.pde:21: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:24: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde: In function ‘void setup()’:
SdFatRewrite.pde:36: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:40: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:43: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:46: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:51: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:53: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:54: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:57: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:61: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:66: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:67: warning: only initialized variables can be placed into program memory area
SdFatRewrite.pde:69: warning: only initialized variables can be placed into program memory area
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h: At global scope:
/home/otrcomm/sketchbook/libraries/SdFat/SdFatUtil.h:37: warning: ‘int FreeRam()’ defined but not used
I can not compile any of the examples provided the SdFat library.
if (!file.open("BENCH.DAT", O_CREAT | O_TRUNC | O_RDWR)) {*
error("open failed");*
}*
// fill buf with known data*
for (uint16_t i = 0; i < (BUF_SIZE-2); i++) {*
_ buf = 'A' + (i % 26);_ * }* * buf[BUF_SIZE-2] = '\r';
buf[BUF_SIZE-1] = '\n';
cout << pstr("File size ") << FILE_SIZE_MB << pstr(" MB\n");
cout << pstr("Buffer size ") << BUF_SIZE << pstr(" bytes\n");
_ cout << pstr("Starting write test, please wait.") << endl << endl;_
_ // do write test*_ * uint32_t n = FILE_SIZE/sizeof(buf);
_ cout <<pstr("write speed and latency") << endl;_
_ cout << pstr("speed,max,min,avg") << endl;_
_ cout << pstr("KB/Sec,usec,usec,usec") << endl;_
for (uint8_t nTest = 0; nTest < WRITE_COUNT; nTest++) {
_ file.truncate(0);_
_ maxLatency = 0;_
_ minLatency = 9999999;_
_ totalLatency = 0;_
_ t = millis();_
for (uint32_t i = 0; i < n; i++) {
uint32_t m = micros();
_ if (file.write(buf, sizeof(buf)) != sizeof(buf)) {_
_ error("write failed");_
_ }_
_ m = micros() - m;_
_ if (maxLatency < m) maxLatency = m;_
_ if (minLatency > m) minLatency = m;_
_ totalLatency += m;_
_ }_
_ file.sync();_
_ t = millis() - t;_
_ s = file.fileSize();_
_ cout << s/t <<',' << maxLatency << ',' << minLatency;_
_ cout << ',' << totalLatency/n << endl;_
_ }_
_ cout << endl << pstr("Starting read test, please wait.") << endl;_
_ cout << endl <<pstr("read speed and latency") << endl;_
_ cout << pstr("speed,max,min,avg") << endl;_
_ cout << pstr("KB/Sec,usec,usec,usec") << endl;_
_ // do read test*_ * for (uint8_t nTest = 0; nTest < READ_COUNT; nTest++) {
_ file.rewind();_
_ maxLatency = 0;_
_ minLatency = 9999999;_
_ totalLatency = 0;_
_ t = millis();_
for (uint32_t i = 0; i < n; i++) {
buf[BUF_SIZE-1] = 0;
uint32_t m = micros();
_ if (file.read(buf, sizeof(buf)) != sizeof(buf)) {_
_ error("read failed");_
_ }_
_ m = micros() - m;_
_ if (maxLatency < m) maxLatency = m;_
_ if (minLatency > m) minLatency = m;_
_ totalLatency += m;_
if (buf[BUF_SIZE-1] != '\n') {
_ error("data check");_
_ }_
_ }_
_ t = millis() - t;_
_ cout << s/t <<',' << maxLatency << ',' << minLatency;_
_ cout << ',' << totalLatency/n << endl;_
_ }_
_ cout << endl << pstr("Done") << endl;_
_ file.close();_
_}_ _******************************************************************_ I get errors:
_ This report would have more information with_
_ "Show verbose output during compilation"_
_ enabled in File > Preferences._ Arduino: 1.0.6 (Linux), Board: "Arduino Mega 2560 or Mega ADK" bench:30: error: ‘SdFat’ does not name a type bench:33: error: ‘SdFile’ does not name a type bench:36: error: ‘ArduinoOutStream’ does not name a type bench.ino: In function ‘void cidDmp()’: bench:42: error: ‘cid_t’ was not declared in this scope bench:42: error: expected `;' before ‘cid’ bench:43: error: ‘sd’ was not declared in this scope bench:43: error: ‘cid’ was not declared in this scope bench:46: error: ‘cout’ was not declared in this scope bench:46: error: ‘pstr’ was not declared in this scope bench:47: error: ‘hex’ was not declared in this scope bench:47: error: ‘cid’ was not declared in this scope bench:47: error: ‘dec’ was not declared in this scope bench:47: error: ‘endl’ was not declared in this scope bench.ino: In function ‘void setup()’: bench:65: error: ‘cout’ was not declared in this scope bench:65: error: ‘pstr’ was not declared in this scope bench:68: error: ‘uppercase’ was not declared in this scope bench:68: error: ‘showbase’ was not declared in this scope bench:68: error: ‘endl’ was not declared in this scope bench.ino: In function ‘void loop()’: bench:82: error: ‘cout’ was not declared in this scope bench:82: error: ‘pstr’ was not declared in this scope bench:86: error: ‘FreeRam’ was not declared in this scope bench:86: error: ‘endl’ was not declared in this scope bench:90: error: ‘sd’ was not declared in this scope bench:90: error: ‘SPI_FULL_SPEED’ was not declared in this scope bench:92: error: ‘sd’ was not declared in this scope bench:99: error: ‘file’ was not declared in this scope bench:99: error: ‘O_CREAT’ was not declared in this scope bench:99: error: ‘O_TRUNC’ was not declared in this scope bench:99: error: ‘O_RDWR’ was not declared in this scope bench:120: error: ‘file’ was not declared in this scope bench:148: error: ‘file’ was not declared in this scope bench:172: error: ‘file’ was not declared in this scope Thank you in advance for your help, Murrah Boswell
I installed the SdFat library automatically using the 1.0.6 IDE and it got installed in my .../sketchbook/libraries directory. Then, at your suggestion, I removed it from my sketchbook/libraries folder and reinstalled it manually in my ../arduino-1.0.6/ibraries directory and got these errors trying to compile bench:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Linux), Board: "Arduino Mega 2560 or Mega ADK"
bench:30: error: ‘SdFat’ does not name a type
bench:33: error: ‘SdFile’ does not name a type
bench:36: error: ‘ArduinoOutStream’ does not name a type
bench.ino: In function ‘void cidDmp()’:
bench:42: error: ‘cid_t’ was not declared in this scope
bench:42: error: expected `;' before ‘cid’
bench:43: error: ‘sd’ was not declared in this scope
bench:43: error: ‘cid’ was not declared in this scope
bench:46: error: ‘cout’ was not declared in this scope
bench:46: error: ‘pstr’ was not declared in this scope
bench:47: error: ‘hex’ was not declared in this scope
bench:47: error: ‘cid’ was not declared in this scope
bench:47: error: ‘dec’ was not declared in this scope
bench:47: error: ‘endl’ was not declared in this scope
bench.ino: In function ‘void setup()’:
bench:65: error: ‘cout’ was not declared in this scope
bench:65: error: ‘pstr’ was not declared in this scope
bench:68: error: ‘uppercase’ was not declared in this scope
bench:68: error: ‘showbase’ was not declared in this scope
bench:68: error: ‘endl’ was not declared in this scope
bench.ino: In function ‘void loop()’:
bench:82: error: ‘cout’ was not declared in this scope
bench:82: error: ‘pstr’ was not declared in this scope
bench:86: error: ‘FreeRam’ was not declared in this scope
bench:86: error: ‘endl’ was not declared in this scope
bench:90: error: ‘sd’ was not declared in this scope
bench:90: error: ‘SPI_FULL_SPEED’ was not declared in this scope
bench:92: error: ‘sd’ was not declared in this scope
bench:99: error: ‘file’ was not declared in this scope
bench:99: error: ‘O_CREAT’ was not declared in this scope
bench:99: error: ‘O_TRUNC’ was not declared in this scope
bench:99: error: ‘O_RDWR’ was not declared in this scope
bench:120: error: ‘file’ was not declared in this scope
bench:148: error: ‘file’ was not declared in this scope
bench:172: error: ‘file’ was not declared in this scope
Thank you for your patience. Now I understand. I did copy the SdFat directory with SdFat.h into my sketchbook/libraries and as you said, that was the solution. I can now link to the SdFat libraries.
The arduino 1.5.8 install path on my windows 8 x64 is: E:\Downloads\Arduino\arduino1.5.8_homeduino
The path to SdFat.h library is C:\Users\Packy\Documents\Arduino\libraries\SdFat\SdFat.h
gives:
FunkcontroloverNet.ino:13:19: fatal error: SdFat.h: No such file or directory
compilation terminated.
So i moved the SdFat.h library to E:\Downloads\Arduino\arduino1.5.8_homeduino\sketchbook\libraries\SdFat\SdFat.h
gives:
FunkcontroloverNet.ino:19:1: error: 'Sdvol' does not name a type
FunkcontroloverNet.ino: In function 'void setup()':
FunkcontroloverNet.ino:63:3: error: 'vol' was not declared in this scope