Go Down

Topic: List only *.csv files (Read 3 times) previous topic - next topic

marco_c

This
Code: [Select]
(fname == file_list)

will never do what you expect it to do. You are comparing if the addresses (pointers) of the two strings are the same.

If you want to compare whether the strings are the same you need to use the strcmp() function, like you were in previous code to compare the file extension.
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Onenate

thanks for that works a treat

Code: [Select]
    if (strcmp(fname,file_list) == 0)

now I just need to get it to delete the file it just does not seem to work with anything I try if, I open the file then delete it, or just try and delete it still no luck. 


Code: [Select]


dfile.open(fname);
               dfile.remove();
                Serial.print("File Removed");

Onenate

okay if I add the remove file command it does not complete the files are still their, it also stuff up the uploading of the file

but I need to remove these files some how.

any ideas


marco_c

Have you tried any of the examples for the libraries to see how you can use remove()
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Onenate

yer I have checked out the remove commands and everything I have tried nothing seems to deleted it ,

Another strange issue it does not seem to loop it only list the files ones then that it any ideas why or what I should change?

Code: [Select]
#include <SdFat.h>
#include <SdFile.h>
#include <SdBaseFile.h>

// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;
SdFile file;
SdBaseFile lFile;
uint16_t count; // count of files
int const file_size =12;
char fname[file_size];
char file_list[] = "FILELIST.TXT";
char *CSV_EXT = "CSV";
#define SD_SELECT 4

// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
           
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);


if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

Serial.println("program started");


}



void loop() {
delay(500);
count = 0;
while (file.openNext(sd.vwd(), O_READ));

    if (file.isFile())
{ file.getFilename(fname);
if (strcmp(CSV_EXT, &fname[strlen(fname)-strlen(CSV_EXT)]) == 0){
                Serial.println(fname);
                count++;
}
}
file.close();

}
count = count = 0;
}

Go Up