hi,
i try to put a filename to a variable. I use the sdFat library. later i want to compear the first two chars of the name with a integer. But my biggest problem is get the filename. This is what i tried:
#include <SPI.h>
#include "SdFat.h"
#include <SdFatutil.h>
// SD default chip select pin.
const uint8_t chipSelect = 4;
// file system object
SdFat sd;
SdFile file;
byte currentDir=9;
byte track=3;
void setup() {
Serial.begin(9600);
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
sd.initErrorHalt();
}
char dirName[4]=""; //----
sprintf(dirName,"%02i",currentDir); // |
strcat(dirName,"/"); // V
sd.chdir(dirName); //go to current directory
getFileName(); //read name of the file
}
void loop() {
// put your main code here, to run repeatedly:
}
void getFileName(){
char* fBuffer;
while (file.openNext(sd.vwd(), O_READ)) {
file.getName(fBuffer,13);
file.printName(&Serial);
Serial.println();
file.close();
}
}
the help of the sdFat
bool FatFile::getName ( char * name,
size_t size
)
Get a file's name followed by a zero byte.
Parameters
[out] name An array of characters for the file's name.
[in] size The size of the array in bytes. The array must be at least 13 bytes long. The file's name will be truncated if the file's name is too long.
Returns
The value true, is returned for success and the value false, is returned for failure.
but i don't understand how to use this.
can anyone pleas help me?