dave@huckleberrycove.ca
Member
Hello
I have been struggling with using an SD card with a Teensy 3.2. Some of the example code works and my sometime my code works. I have had many years of coding in C, C++, C# and Java but am quite new to the Arduino environment. I am running under Linux.
I think I could sort out my own problems if I could discover which header and cpp files are actually being used in the build process. For Example, if I do
#include <SdFat.h>
then create a file in global space (before setup())
SdFat sd;
// Log file.
SdFile fileSD;
uint8_t bLogging = true;
uint8_t bFileOpen = false;
in setup()
if (!sd.begin(csSD, SPI_QUARTER_SPEED)) {
Serial.println("sd.begin failed");
}
else {
Serial.println("sd.begin ok at 1/4 speed");
}
and then in my code
....
// open the file for write
if (bFileOpen) fileSD.close();
while(fileSD.isOpen()) ;
bFileOpen = fileSD.open(filename.c_str(), O_WRITE | O_CREAT | O_AT_END);
if (verbosity > 0) {
cout << "Open File " << filename.c_str() << " ";
if (bFileOpen)
cout << "OK" << endl;
else
cout << "Failed" << endl;
}
...
It sometimes opens the file and will write to it and sometimes fails. I would like to examine the source code for SdFile:pen() (and close and isOpen) but I cannot discover which library files are being used. In fact I cannot find (Grep'ing around) any SdFilepen() that only takes two parameters. But this works a half of the time. The code in the example dataLogger, which makes a similar call, works properly.
I would really like to find the library code that is being used in the build. Is there any thing in the IDE which will allow me to discover which SdFat.h is used and which .cpp it is connected to?
Dave Heffler
I have been struggling with using an SD card with a Teensy 3.2. Some of the example code works and my sometime my code works. I have had many years of coding in C, C++, C# and Java but am quite new to the Arduino environment. I am running under Linux.
I think I could sort out my own problems if I could discover which header and cpp files are actually being used in the build process. For Example, if I do
#include <SdFat.h>
then create a file in global space (before setup())
SdFat sd;
// Log file.
SdFile fileSD;
uint8_t bLogging = true;
uint8_t bFileOpen = false;
in setup()
if (!sd.begin(csSD, SPI_QUARTER_SPEED)) {
Serial.println("sd.begin failed");
}
else {
Serial.println("sd.begin ok at 1/4 speed");
}
and then in my code
....
// open the file for write
if (bFileOpen) fileSD.close();
while(fileSD.isOpen()) ;
bFileOpen = fileSD.open(filename.c_str(), O_WRITE | O_CREAT | O_AT_END);
if (verbosity > 0) {
cout << "Open File " << filename.c_str() << " ";
if (bFileOpen)
cout << "OK" << endl;
else
cout << "Failed" << endl;
}
...
It sometimes opens the file and will write to it and sometimes fails. I would like to examine the source code for SdFile:pen() (and close and isOpen) but I cannot discover which library files are being used. In fact I cannot find (Grep'ing around) any SdFilepen() that only takes two parameters. But this works a half of the time. The code in the example dataLogger, which makes a similar call, works properly.
I would really like to find the library code that is being used in the build. Is there any thing in the IDE which will allow me to discover which SdFat.h is used and which .cpp it is connected to?
Dave Heffler