I have a program that is written using SDfat. I'm trying to implement MTP Responder which uses SD and was told by @WMXT to use SD. I was told that SD is now the same as SDfat(https://forum.pjrc.com/threads/43050-MTP-Responder-Contribution/page39) but if I simply change #include "SdFat.h" to #include "SD.h" I now get a file open error when creating or opening a file for writing. The sd.begin() seems to work and returns that the function completed successfully. My program compiles without any error messages.
My initialization:
File open and write:
What do in need to change to correct the file open?
Is the SD lib included with Arduino / Teensyduino the same as the Greiman Git version SDfat?
My initialization:
Code:
//Setup for SdFat lib *************************************
//#include "SdFat.h"
#include "SD.h"
#define USE_EXTERNAL_SD //Comment out if using internal SD card
#ifdef USE_EXTERNAL_SD
const uint8_t SD_CS_PIN = SS;
#define SPI_CLOCK SD_SCK_MHZ(10)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#else // Use built in SD card.
#ifdef SDCARD_SS_PIN
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN
// Setup for built in SD card.
#define SPI_CLOCK SD_SCK_MHZ(50)
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#endif // USE_EXTERNAL_SD
SdFs sd; // SdFat usage
FsFile myFile;
File open and write:
Code:
String time = GetTimeNow(); //get the datetime, store in var time
Serial.print("Attempting Open file- "); //print to Serial open file msg
filename = get_Date(); //get the date for the file name
filename += ".txt"; //make the file name (date + .txt)
Serial.println(filename); //print the file name to Serial
Serial.println(GetTimeNow());
myFile = sd.open(filename.c_str(), FILE_WRITE); //open the SD file for writing
if (myFile) { //if file opened okay, write to it
myFile.print(time); //print the time to SD
myFile.println(s3); //on the same line print the csv data string + crlf
myFile.close(); //close the file on SD
Serial.println("File write done."); //Serial print "done" if no errors
Serial.println("");
}
else {
Serial.println("SD Card Error");
Serial3.println("SD Card Error");
Serial3.print("error opening- "); //else, if the file didn't open, print an error msg
Serial3.println(filename); //with the file name on Serial3
}
What do in need to change to correct the file open?
Is the SD lib included with Arduino / Teensyduino the same as the Greiman Git version SDfat?