<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>fds_record_find returns files that do not exist</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24476/fds_record_find-returns-files-that-do-not-exist</link><description>Hi 
 I&amp;#39;m trying to use fds_record_find() to detect if a record exists in flash storage. After erasing the device (via nrfjprog), flashing the softdevice, flashing the program, and calling fds_file_delete(my_file_id) , fds_record_find(my_file_id, my_record_key</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Aug 2017 13:20:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24476/fds_record_find-returns-files-that-do-not-exist" /><item><title>RE: fds_record_find returns files that do not exist</title><link>https://devzone.nordicsemi.com/thread/96366?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2017 13:20:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4cea3d5-5a00-4dfb-914c-94185bba0e3b</guid><dc:creator>q</dc:creator><description>&lt;p&gt;Thanks.  I was calling fds_record_find() almost immediately after power up.  After waiting a couple seconds and calling the function as I normally would during operation, it functioned normally.  I don&amp;#39;t know if the early call to fds_record_find() exposed a bug in fds, or (probably more likely) moving the call changed something else in my code.  Either way it works now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fds_record_find returns files that do not exist</title><link>https://devzone.nordicsemi.com/thread/96365?ContentTypeID=1</link><pubDate>Sat, 19 Aug 2017 09:34:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a13a8fce-fa2d-4d9f-8914-2b7380e3addb</guid><dc:creator>RichieJH</dc:creator><description>&lt;p&gt;If you have truly erased the chip, the flash would be cleared and there would be no records.  So calling &lt;code&gt;fds_file_delete()&lt;/code&gt; would be ineffective and there would be no records to find.  If you didn&amp;#39;t erase the chip, a successful &lt;code&gt;fds_file_delete()&lt;/code&gt; would also prevent you from being able to find a record with that FILE_ID, even if you didn&amp;#39;t use gc since the library marks the file as unavailable.  The nRF will predominantly find a record faster than it can be deleted due to the asynchronous nature of deleting so you need to use a flag when calling fds_file_delete() that is then cleared in the &lt;code&gt;fds_evt_handler&lt;/code&gt; before calling &lt;code&gt;fds_record_find()&lt;/code&gt;.  Something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void my_fds_evt_handler(fds_evt_t const * const p_fds_evt)
{
    switch (p_fds_evt-&amp;gt;id)
    {
        case FDS_EVT_DEL_FILE:
            if (p_fds_evt-&amp;gt;result == FDS_SUCCESS)
            {
		        write_flag=1;
            }
            break;

        default:
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>