Code Monkey home page Code Monkey logo

Comments (23)

greiman avatar greiman commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

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.

greiman avatar greiman commented on August 16, 2024

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.

greiman avatar greiman commented on August 16, 2024

http://eclipse.baeyens.it/how_to.shtml#/lib

Ask a 'Sloeber' expert for more help.

from sdfat.

420579436 avatar 420579436 commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

To add a library to Eclipse is very simple.
That is not the reason for the issue.

from sdfat.

420579436 avatar 420579436 commented on August 16, 2024

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.

greiman avatar greiman commented on August 16, 2024

I don't use 'Sloeber' and can't help you.

from sdfat.

420579436 avatar 420579436 commented on August 16, 2024

It's NOT a Eclipse/Sloeber problem!!!

Question:
Why works 'SdFile my_file;' and 'SdFat SD;' not in another library?

from sdfat.

greiman avatar greiman commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

As I already mentioned.
The SdFat library works in a program but not in another library

from sdfat.

420579436 avatar 420579436 commented on August 16, 2024

P.S.
Eclipse/Sloeber and Arduino use the same compiler.

from sdfat.

greiman avatar greiman commented on August 16, 2024

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.

greiman avatar greiman commented on August 16, 2024

#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.

greiman avatar greiman commented on August 16, 2024

This works with the Arduino IDE.

#include "SdFat.h"
#include "FatLib/ArduinoFiles.h"
void setup() {
}
void loop() {
}

from sdfat.

stevstrong avatar stevstrong commented on August 16, 2024

Instead
SdFat SD;
use
SdFat my_sd;
because SD may be reserved.

from sdfat.

420579436 avatar 420579436 commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

#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.

420579436 avatar 420579436 commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

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.

greiman avatar greiman commented on August 16, 2024

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.

420579436 avatar 420579436 commented on August 16, 2024

No comment
Issue closed unsolved

from sdfat.

Related Issues (20)

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.