<?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>Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7380/checking-if-data-is-correct-in-pstorage-callback</link><description>Hi, 
 As i wrote in the topic, after calling pstorage_update I would like to check if the data was stored correctly. Can I call another pstorage_update in pstorage callback, if the data was corrupted? 
 For now the callback looks like this, but I can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Jun 2015 10:42:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7380/checking-if-data-is-correct-in-pstorage-callback" /><item><title>RE: Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/thread/26226?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2015 10:42:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:208edf7d-7b8c-48b7-b6c1-14ee14a5994c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Is there anything else you are looking for in this thread? if not can you please accept and close this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/thread/26225?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2015 10:24:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bfbf641-34bb-4cb5-99be-b2ee9a4cfd38</guid><dc:creator>Konrad Traczyk</dc:creator><description>&lt;p&gt;Ok, many thanks :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/thread/26224?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2015 10:20:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa6179cf-7a59-45d5-bc67-7f6318c068b4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi
You are right, The callback does not provide any information on the offset used. So if you want to verify data then offset has to be remembered so how.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/thread/26223?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2015 10:09:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eaf37ea-ca5e-4a66-8d3f-68e671e4e4ee</guid><dc:creator>Konrad Traczyk</dc:creator><description>&lt;p&gt;Thanks for reply. You&amp;#39;re right, I didn&amp;#39;t set the guardian counter which guards against infinit flash update. The data_len is never bigger than 8, so it is ok. I just realised, that when I register one block with sufficient size, where I store different data, the callback doesn&amp;#39;t provide any information about offset where I&amp;#39;ve just stored the data in flash. Am I correct that for that reason I am not able to check if the data wasn&amp;#39;t corrupted?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Checking if data is correct in pstorage callback</title><link>https://devzone.nordicsemi.com/thread/26222?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 18:26:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6f06430-b4b8-4ca1-bf43-b7a3eb1bcb4f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;pre&gt;&lt;code&gt;for(uint8_t i=0; i&amp;lt;8; i++)
{
     p_dataCheck[i] = p_data[i];       //  Copy the data which were just stored, for debug
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you are copying only 8 bytes to p_data_check but&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for(uint8_t i=0; i&amp;lt;data_len; i++)
{
   if(p_dataCheck[i] != temp[i]) 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you are comparing data_len bytes, this is fine if you are sure that data_len will always be 8.&lt;/p&gt;
&lt;p&gt;Why do you have a waiting &amp;#39;for loop&amp;#39; for the second update to complete? I think it is best to break out of this handler as fast as possible without waiting.&lt;/p&gt;
&lt;p&gt;You have written very dangerous code. If something goes wrong, you could end up in endless loop of flash writes, damaging flash memory within hour if not minutes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>