<?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>Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17748/handling-fds_write-event-before-reading-from-flash</link><description>Hi, 
 I am having a 324 byte,a 420 bytes of array stored in flash,now i am updating these array with 360 bytes. in fds_event_handler in the case FDS_EVT_WRITE i am reading flash again 
 static void fds_event_handler(fds_evt_t const * const p_fds_evt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Nov 2016 16:15:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17748/handling-fds_write-event-before-reading-from-flash" /><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68340?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 16:15:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d67f5425-7e1a-40b2-8e08-fb1eabba6f5c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;It is difficult to understand what you are doing with the record keys, I don&amp;#39;t understand why you are changing them. Anyways, could you zip your complete project, edit the question and attach it there? So I can test it here? Also, what SDK and SoftDevice version are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68338?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 13:29:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12b6b8ca-4809-4f3b-8590-c65a49ab57d7</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;arguments given to fds_write() are a 2 dimensional array,record_write parameter which will add to 0x2222 to get record key.size of model this is actually number of rows in model_array which will be multiplied by 3 to give the length_words.&lt;/p&gt;
&lt;p&gt;i am testing this when I am reading from flash.
i verified at every point that the data is not corrupted till the function fds_write() is called. means i am getting proper values of array before giving to fds_write().&lt;/p&gt;
&lt;p&gt;in the last 5 rows i am getting back zero,but there should be some value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68336?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 13:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:233752f6-90db-4073-8a8a-d34133f72768</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;And how are you testing this? How are you using fds_write()? What arguments do you give to the function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68339?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 12:26:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40847205-284d-4ff5-8863-104989557888</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;I have found that during fds_record_update i was not providing the record_desc.record_id. that is why it was giving record not found.Now i am able to update.
But the issue of last few bytes not been written is still there. I am attaching updated fds_write code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static ret_code_t fds_write(float  model_array[][3],uint16_t record_write,uint16_t size_of_model)

{

	fds_record_t        record;

	fds_record_desc_t   record_desc;

	fds_record_chunk_t  record_chunk;

	record_chunk.p_data         =  model_array;

	record_chunk.length_words   =  size_of_model*3;

	record.file_id              =  FILE_ID;

	record.key                  =  REC_KEY+record_write;

	record.data.p_chunks        =  &amp;amp;record_chunk;

	record.data.num_chunks      =  1;

	record_desc.record_id       =  record_write+1;//imp line when you are using fds_record_update.

	ret_code_t ret;

	ret = fds_record_update(&amp;amp;record_desc,&amp;amp;record);

	return ret;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68335?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 10:13:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32893fc6-5785-4f1c-9bb9-58a7a1ff2de2</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. Maybe you can include some code that shows how you are doing this? I&amp;#39;m guessing it has changed from the code in the question?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68337?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 08:40:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7abe6d81-bdc9-4365-a1be-7e7c59e6233b</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Here I  tried to add larger and smaller array than previously stored data,and I am using fds_record_delete() followed by  fds_record_write() , I found that the last 60 bytes are not updating.&lt;/p&gt;
&lt;p&gt;I am not using fds_record_update because it provide me with error of FDS_ERR_NO_SPACE_IN_FLASH and also FDS_ERR_NOT_FOUND.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68333?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2016 14:03:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:293c7cc0-bf4a-4cc1-a073-ffb58dfccbb8</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;It seems you can put more data into the record, have you experienced anything else?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68334?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2016 12:54:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ce9108f-78d7-4170-b531-588723810183</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;one more thing data length should be same for update? means can i give array of larger or smaller length than previously stored data,while calling fds_record_update().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68332?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2016 11:05:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc6f2c2-eddd-4070-b19b-9ad743ab57a2</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The record key will be whatever you give to fds_record_update().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68331?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 12:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9a57ed3-d1dc-4952-9c24-e68807980dfa</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;When fds_record_update() is called it will create a new record and delete the older one.So the question is that the REC_KEY is changed during this process,or it will update the record with the same REC_KEY.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68330?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 10:09:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90cafd56-2904-4cdd-90c6-ed902e2a582c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand, please clarify.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68328?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 13:38:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdae5efe-297b-4bdf-9ff9-baaae431e021</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;i have commented that delete part already and then checked it.Is that possible that fds_record_update() when create a new record change the REC_KEY.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68329?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 11:23:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:144dea21-7f37-46d9-8401-4b11a99e56d6</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I think fds_record_update() can&amp;#39;t find the record because it is deleted. Why are you deleting the record before you update?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68327?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 07:23:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8b8da87-e8d4-4e6a-bf5b-20c407231c64</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Hi Petter,
I debbuged the error and found fds_record_update is returning FDS_ERR_NOT_FOUND. how to solve this problem
while if i am using fds_delete_record and then fds_record_write i am able to write few values not all.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68326?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 14:41:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52f07706-344f-4615-a184-0b4ebdf3f770</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Thanks Petter for clearing things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68325?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 14:35:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a69fc59f-4d5c-408e-9741-f38f885027ef</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Yes. If you call fds_record_write() you will get a FDS_EVT_WRITE event. If the result is FDS_SUCCESS the write operation is complete.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68324?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 14:33:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cdc645a-04d5-45da-a272-c8511101dd75</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;In the case FDS_EVT_WRITE in fds_event_handler(),if result is FDS_SUCSESS this just means that the write event is completed ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68323?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 14:23:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6791f86c-92c1-420b-bf03-7279c6840450</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Put in a case for FDS_EVT_UPDATE in fds_event_handler(). When you get this event and the result is FDS_SUCCESS, an update operation is complete.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68322?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 12:56:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5b37c2f-2551-41aa-8f03-735f8eda3f02</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Hi Petter,
Thanks for response,I was thinking if you could point me in direction that how to wait for the fds_evt_update to complete.should i put delay or any other suggestion.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling Fds_write event before reading from flash.</title><link>https://devzone.nordicsemi.com/thread/68321?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 12:44:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:077bc9b2-998d-4a59-b6dc-d710f073d113</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand what the problem is, or what you are seeing, but:&lt;/p&gt;
&lt;p&gt;Why are you deleting the record before you update it? fds_record_update will write the new record to flash and then delete the old record.&lt;/p&gt;
&lt;p&gt;Why are you not checking the returned error of the functions? If they don&amp;#39;t return FDS_SUCCESS you will not know if the operation was queued successfully.&lt;/p&gt;
&lt;p&gt;Why are you not waiting for the events that tell you that the operation completed successfully? FDS_EVT_UPDATE, FDS_EVT_DEL_RECORD and FDS_EVT_GC?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>