cancel
Showing results for 
Search instead for 
Did you mean: 

Update file on FAT SF on the fly

dkilshtein9
Associate II
Posted on December 04, 2012 at 12:50

Sorry for the trivial question but I need to add some data to a text file on the fly.

Each time I need to open an existing file and add a line of text to it then close (to avoid data loss on power off)

I'm new to a FS programming and I can't find the option for append (a+). Can I do it on the stm3220g-eval? Do I have to read the entire file content then create a new file to store the data in it?

#stm3220g-eval #fs-f_lseek-stm3220g-eval #fat-stm32 #file-system #filesystem #fatfs
3 REPLIES 3
Posted on December 04, 2012 at 14:53

Trivial in the sense you could read the documentation, use FA_OPEN_ALWAYS, along with FA_READ/WRITE, and f_lseek to the end of the file

http://elm-chan.org/fsw/ff/en/open.html

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on December 04, 2012 at 14:56

Do you mean FatFs ?

If so, the documentation is here:

http://elm-chan.org/fsw/ff/00index_e.html

 - note also the Resources links...

''Each time I need to open an existing file and add a line of text to it then close (to avoid data loss on power off)''

If you are using FatFs, see:

http://elm-chan.org/fsw/ff/en/sync.html

FatFs, Filesystem, File System
dkilshtein9
Associate II
Posted on December 04, 2012 at 19:47

Thanks a lot,

I fund the f_lseek but it didn't work(it kept crashing) . Then I found the bug in a whole different location.

Now it works perfectly!!!