FatFs R0.13c, released October 14, 2018
This commit is contained in:
+24
-1
@@ -44,7 +44,30 @@ FRESULT f_sync (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function of periodic or immediataly after <tt>f_write</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
|
||||
<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function in certain interval can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
|
||||
<pre>
|
||||
Case 1. Normal write sequence
|
||||
|
||||
Time --> ↓Power off after close
|
||||
OwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwC
|
||||
|
||||
|
||||
Case 2. Without using f_sync()
|
||||
|
||||
Time --> ↓System crush
|
||||
O<span class="e">wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww</span>
|
||||
|<--------------- All data written will be lost ------------------>|
|
||||
|
||||
|
||||
Case 3. Using f_sync()
|
||||
Time --> ↓System crush
|
||||
OwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwS<span class="e">wwwww</span>
|
||||
Data after last f_sync will be lost |<->|
|
||||
O - f_open()
|
||||
C - f_close()
|
||||
w - f_write()
|
||||
S - f_sync()
|
||||
</pre>
|
||||
<p>However there is no sense in <tt>f_sync</tt> function immediataly before <tt>f_close</tt> function because it performs <tt>f_sync</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user