okay I have tired to simplify the code if I comment out the //if (plFile.open(file_list, O_CREAT|O_WRITE)); the code works
but when I add it back in with the if (plFile.open(file_list, O_CREAT|O_WRITE)); or even with out plFile.open(file_list, O_CREAT|O_WRITE);
it completes but skips the openNext command, I am using IDE 1.0.3 and the lastest SDFAT library
#include <SdFat.h>
#include <SdFile.h>
// SD chip select pin
const uint8_t chipSelect = SS;
// file system object
SdFat sd;
SdFile file;
SdFile plFile; // Playlist file
SdFile lFile; //list files
uint16_t count; // count of files
int FNAME_SIZE;
char fname[200];
char file_list[] = "FILELIST.TXT";
char *CSV_EXT = "CSV";
// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
//if (plFile.open(file_list, O_CREAT|O_WRITE));
count = 0;
while (file.openNext(sd.vwd(), O_READ))
{
Serial.println("Started");
if (file.isFile())
{ file.getFilename(fname);
if (strcmp(CSV_EXT, &fname[strlen(fname)-strlen(CSV_EXT)]) == 0){
Serial.print(fname);
plFile.write(fname, 100);
count++;
}
}
file.close();
}
plFile.close();
Serial.println("count");
Serial.print(count);
}
void loop() {}