Hi,
I'm using FatFs with SDSPI.
It works good but after some write logs , can't find file with 'fopen()'.
this is my code
//Check if the file exists. 'datalogfile' is string with file name pFiledatalog = fopen(datalogfile, "r"); //if file is not exist, make file and write header text. 'textarray' is string with header text. if(!pFiledatalog) { pFiledatalog = fopen(datalogfile, "a"); if (pFiledatalog) { fwrite(textarray, 1, strlen(textarray), pFiledatalog); fflush(pFiledatalog); fclose(pFiledatalog); } } //open file and write new log at the end of the logs. 'databuf' is string with log text. pFiledatalog = fopen(datalogfile, "a"); if (pFiledatalog) { fseek(pFiledatalog, 0, SEEK_END); fwrite(databuf, 1, strlen(databuf), pFiledatalog); fflush(pFiledatalog); fclose(pFiledatalog); }
the output looks like this.
//////////////////////////////////////////
header text
log1
log2
log3
.
.
.
//////////////////////////////////////
it works great but after some write, fopen(datalogfile, "a") returns null pointer. around write 7 logs
this is SDSPI initial code
SDSPI_Handle sdspiHandle; SDSPI_Params sdspiParams; SDSPI_Params_init(&sdspiParams); sdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &sdspiParams);