cancel
Showing results for 
Search instead for 
Did you mean: 

How to use FA_OPEN_APPEND in sd card

dbgarasiya
Senior II

I want to write data to already created file in sd card 

I have tried use of FA_OPEN_APPEND 

I am not able to write data in that file 

Best Regards

Dipak Garasiya

5 REPLIES 5
dbgarasiya
Senior II

Any One ,Help me out

Getting errors?

Seeking to the end of the files?​

What is happening?

Posted examples of adding​ line to a log file to the forum previously, look at those.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Had this for incrementation updating

  1. ...
  2. // Incremental write test
  3. if (f_open(&fil, "LOG.TXT", FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
  4. {
  5. UINT BytesWritten;
  6. const char string[] = "Another line gets added";
  7. f_lseek(&fil, fil.fsize);
  8. f_write(&fil, string, strlen(string), &BytesWritten);
  9. f_close(&fil);
  10. }

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dbgarasiya
Senior II

Thanks for replying ,

that working fine

and ofcourse i have another method which i am sharing with you is given below

if(f_open(&SDFile, "sdtest.txt", FA_OPEN_APPEND | FA_WRITE) == FR_OK)                

{

int len = f_size(&SDFile);

if(len != 0 ) len+=2;

f_lseek(&SDFile,len);

res = f_write(&SDFile, wtext, sizeof(wtext), (void *)&byteswritten);

if((byteswritten > 0) && (res == FR_OK))

{

printf("SD Card written successfully \n\r");

f_close(&SDFile);

}

  }

Thanks for helping

dbgarasiya
Senior II

Thanks for supporting