Good evening,
I can write and save data into a folder structure of my SD card.
Actually, I am trying to read a file.
As long as the file is at the roor, I can do it, but I can not specify a folder path.
For exemple, I am trying to read that files
/2015/12/25/14-20-20.TXT
and
/14-20-20.TXT
With the following code, I can read the file which is at the root
char param[170];
sd_read(NULL, param); // I set temporarely NULL and I set the path in the fonction
SerialUSB.println(param);
void sd_read(char * fileName, char * param)
{
int i =0;
if(isSdReady == true)
{
char buff[PARAMSIZE];
memset(param, '\0', PARAMSIZE);
#ifdef LOGGER
if(isSdReady == true)
{
logfile = SD.open("/14-20-20.TXT");
if (logfile)
{
while(logfile.available())
{
//SerialUSB.write(logfile.read());
if(i < PARAMSIZE)
{
param[i++] = logfile.read();
}
else
{
sprint(F("OF param: "),0); sprintln(i,0);
}
}
param[i]='\0';
logfile.close();
}
// if the file isn't open, pop up an error:
else
{
sprint(F("error opening "),2);
sprintln(fileName,2);
}
}
#endif
}
}
This work, but now if I specify folders, it return me "Error opening". (The file exists )
char param[170];
sd_read(NULL, param); // I set temporarely NULL and I set the path in the fonction
SerialUSB.println(param);
void sd_read(char * fileName, char * param)
{
int i =0;
if(isSdReady == true)
{
char buff[PARAMSIZE];
memset(param, '\0', PARAMSIZE);
#ifdef LOGGER
if(isSdReady == true)
{
logfile = SD.open("/2015/12/25/14-20-20.TXT");
if (logfile)
{
while(logfile.available())
{
//SerialUSB.write(logfile.read());
if(i < PARAMSIZE)
{
param[i++] = logfile.read();
}
else
{
sprint(F("OF param: "),0); sprintln(i,0);
}
}
param[i]='\0';
logfile.close();
}
// if the file isn't open, pop up an error:
else
{
sprint(F("error opening "),2);
sprintln(fileName,2);
}
}
#endif
}
}
How can I go to directorie and read my files?
Is there a cd command?
Thank for your help and happy christmas!