Skip to main content
dbgarasiya
Senior
December 19, 2019
Question

How to use FA_OPEN_APPEND in sd card

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

    This topic has been closed for replies.

    5 replies

    dbgarasiya
    Senior
    December 21, 2019

    Any One ,Help me out

    Tesla DeLorean
    Guru
    December 21, 2019

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    December 21, 2019

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    dbgarasiya
    Senior
    December 23, 2019

    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
    December 28, 2019

    Thanks for supporting