Comments (23)
You will need to add an extern declaration to access the SD object you create in cpp files. I don't create SD like the SD.h wrapper for the six year old version of SdFat since there are now too many options for this to work in all cases.
extern SdFat SD;
from sdfat.
I use the Eclipse 'Sloeber' IDE instead the Arduino IDE.
The SdFat library directory is in the same directory as e.g. the SPI library and Wire library directories.
If I include SdFat in the 'program' file, it works.
I have the problem only if I want to include the SdFat library in other libraries.
from sdfat.
I don't know how you cause third party libraries to be in the include list for 'Sloeber' IDE.
Eclipse has the ability to add an include path.
from sdfat.
http://eclipse.baeyens.it/how_to.shtml#/lib
Ask a 'Sloeber' expert for more help.
from sdfat.
Eclipse has included the SdFat library and shows that the SdFat library has a problem to include the ArduinoFiles.h library.
The include SdFat.h works in a 'program' file, but not if included in another library.
from sdfat.
To add a library to Eclipse is very simple.
That is not the reason for the issue.
from sdfat.
I found another issue.
Maybe it helps.
if (!SD.exists("/MY_DIR")) { SD.mkdir("/MY_DIR"); } creates the file 'MY_DIR'!!
Only SD.mkdir("/MY_DIR"); creates the directory 'MY_DIR'.
from sdfat.
I don't use 'Sloeber' and can't help you.
from sdfat.
It's NOT a Eclipse/Sloeber problem!!!
Question:
Why works 'SdFile my_file;' and 'SdFat SD;' not in another library?
from sdfat.
This program seems to work fine.
#include <SPI.h>
#include "SdFat.h"
SdFat SD;
void setup() {
Serial.begin(9600);
Serial.println("Type any character");
while (!Serial.available());
if (!SD.begin()) {
Serial.println("begin");
while(1);
}
Serial.println(SD.exists("/MY_DIR"));
if (!SD.exists("/MY_DIR")) { SD.mkdir("/MY_DIR"); }
Serial.println(SD.exists("/MY_DIR"));
Serial.println("Done");
}
void loop() {}
Type any character
0
1
Done
from sdfat.
As I already mentioned.
The SdFat library works in a program but not in another library
from sdfat.
P.S.
Eclipse/Sloeber and Arduino use the same compiler.
from sdfat.
Ask a Sloeber user about this. The include path can be a problem when you include a library in a library.
For example, if you want to include ArduinoFiles.h
#include "ArduinoFiles.h"
May not work since the file is located at"
libraries/SdFat/src/FatLib/ArduinoFiles.h
from sdfat.
#include "SdFat.h"
#include "ArduinoFiles.h"
void setup() {
}
void loop() {
}
Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\bill\Documents\ArduinoSdFs\sketch_feb16a\sketch_feb16a.ino:2:25: fatal error: ArduinoFiles.h: No such file or directory
#include "ArduinoFiles.h"
from sdfat.
This works with the Arduino IDE.
#include "SdFat.h"
#include "FatLib/ArduinoFiles.h"
void setup() {
}
void loop() {
}
from sdfat.
Instead
SdFat SD;
use
SdFat my_sd;
because SD
may be reserved.
from sdfat.
Ask a Sloeber user about this. The include path can be a problem when you include a library in a library.
For example, if you want to include ArduinoFiles.h
#include "ArduinoFiles.h"
May not work since the file is located at"
libraries/SdFat/src/FatLib/ArduinoFiles.h
Dear William,
Many thanks. I have written a couple of libraries for sensors and in this libraries I have included and included other libraries without problems.
The situation is, I want only to replace the old SD library with your much better SdFat library.
My libraries work all with the old SD library but the one by one replacement with your library is very difficult for me.
Thorsten
from sdfat.
#include "SdFat.h"
#include "ArduinoFiles.h"
void setup() {
}
void loop() {
}
Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\bill\Documents\ArduinoSdFs\sketch_feb16a\sketch_feb16a.ino:2:25: fatal error: ArduinoFiles.h: No such file or directory
#include "ArduinoFiles.h"
from sdfat.
Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Uno"
Dear William,
Many thanks for the important information.
You use a Uno and I use a Due.
We are using different compiler!
from sdfat.
I found another issue.
Maybe it helps.
if (!SD.exists("/MY_DIR")) { SD.mkdir("/MY_DIR"); } creates the file 'MY_DIR'!!
Only SD.mkdir("/MY_DIR"); creates the directory 'MY_DIR'.
This issue I don't have with an AVR board like an Uno.
This issue I have with a SAM board like a Due.
Thorsten
from sdfat.
Instead
SdFat SD;
use
SdFat my_sd;
because SD may be reserved.
Many thanks stevstrong.
A very good tip.
But unfortunately the beast (issue) is still alive.
Thorsten
from sdfat.
You expect me to guess you are using a Due?
I don't appreciate your all caps and !!!
It's NOT a Eclipse/Sloeber problem!!!
That does it I don't want to waste more time.
Please learn how to use Eclipse, CDT, and Sloeber. Eclipse and CDT have excellent documentation.
You need understand how gcc finds include files. It's not AVR vs. SAM. It's not the compiler.
Some libraries will work when included in a simple way. Some won't. SdFat has a more complex directory structure. The Sloeber plugin may not discover include files in a sub-directory of the 'src' folder.
I think there is a YouTube video about the include browser.
You should only need to include SdFat.h. SdFat.h includes other needed .h files.
You can always tweak the include paths in CDT. Please read the documentation.
Avr and Due both fail in this example as does STM32, Teensy 3.x, and ESP8266.
#include <SPI.h>
#include "SdFat.h"
#include "ArduinoFiles.h"
void setup() {}
void loop() {}
Arduino: 1.8.1 (Windows 10), Board: "Arduino Due (Programming Port)"
C:\Users\bill\AppData\Local\Temp\arduino_modified_sketch_210703\HelloWorld.ino:3:26: fatal error: ArduinoFiles.h: No such file or directory
#include "ArduinoFiles.h"
This works on avr, Due, and other boards!
#include <SPI.h>
#include "SdFat.h"
SdFat SD;
void setup() {
Serial.begin(9600);
Serial.println("Type any character");
while (!Serial.available());
if (!SD.begin()) {
Serial.println("begin");
while(1);
}
Serial.println(SD.exists("/MY_DIR"));
if (!SD.exists("/MY_DIR")) { SD.mkdir("/MY_DIR"); }
Serial.println(SD.exists("/MY_DIR"));
Serial.println("Done");
}
void loop() {}
Type any character
0
1
Done
from sdfat.
No comment
Issue closed unsolved
from sdfat.
Related Issues (20)
- Questions about file opening mode a+ HOT 2
- Sdfat on stm32 if sd card removed stm32 crash HOT 22
- SDFAT compatibility with Arduino Giga HOT 1
- ExFatLogger vs LowLatencyLogger different behaviour HOT 7
- Running two SdCards are not working HOT 2
- addApbChangeCallback(): duplicate func when using with TFT_eSPI HOT 5
- Problems with Teensy 4.0 and Adafruit XTSD with SdFat. HOT 2
- [question]How to speed up sd writes on Arduino Uno r4? HOT 7
- Examples of SDFat HOT 4
- sdfat does one write to sd and then nothing HOT 1
- SdFat recommended usage for long term data logging HOT 5
- Pin selection for esp8266 HOT 1
- Did not work at ESP32-CAM HOT 6
- MMC_ERASE HOT 2
- Wrapper to fs::FS to use SDfat in ESPAsyncWebserver HOT 6
- pico-sdk only rp2040 implementation HOT 11
- ESP32 S3 always fails to mount card HOT 10
- Unable to format flat Spiflash module with ESP8266 HOT 4
- Mount issues for a Windows-formatted card HOT 35
- SD NAND XTSD01G (surface mounted chip) not formating HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdfat.