<?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>Confusing length handling in nrf_log_frontend.c</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68398/confusing-length-handling-in-nrf_log_frontend-c</link><description>Hello, 
 I am talking about nRF5_SDK_17.0.2_d674dde/components/libraries/log/src/nrf_log_frontend.c. 
 In the case of HEXDUMP there seems to be some inconsistency in the packet length management as per header base.hexdump.len field. 
 If we Iook for all</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Nov 2020 15:59:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68398/confusing-length-handling-in-nrf_log_frontend-c" /><item><title>RE: Confusing length handling in nrf_log_frontend.c</title><link>https://devzone.nordicsemi.com/thread/280673?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 15:59:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08b0cccc-f829-4428-aa95-b88eb309dc39</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I understand your concern and have added your comment to the internal report.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Confusing length handling in nrf_log_frontend.c</title><link>https://devzone.nordicsemi.com/thread/280668?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 15:33:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0b914c5-d33d-4aee-ad80-7eed52f80653</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;FYI, the reason why I had to look into this code is because I am currently investigating some bug, and one of the symptom is logging not working as expected in some circumstances.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Concerning my comment, that was not only a matter of code clarity. If you have code like this :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrf_log_header_t * p_header = (nrf_log_header_t *)&amp;amp;m_log_data.buffer[header_wr_idx &amp;amp; mask];&lt;/code&gt;&lt;br /&gt;&lt;code&gt;p_header-&amp;gt;base.hexdump.severity = severity_mid &amp;amp; NRF_LOG_LEVEL_MASK;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;p_header-&amp;gt;base.hexdump.offset = 0;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;p_header-&amp;gt;base.hexdump.len = length;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;p_header-&amp;gt;base.hexdump.type = HEADER_TYPE_HEXDUMP;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;p_header-&amp;gt;base.hexdump.in_progress = 0;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Then you rely on the compiler to make the&amp;nbsp;&lt;span&gt;p_header-&amp;gt;base.raw word written as an atomic 32bit operation into the circular buffer, which is desirable, as the writing may occur in a different task than the flushing when logging is differed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I think that there is no problem with the current code (because the compiler will probably optimise all the field accesses in register only operation before push all fields in a single 32bit word to the memory), however, even though the in_progress field is set last, such kind of coding, relying on the compiler goodness, is per se problematic : that is why&amp;nbsp;I made this patch, so as to be 200% that the issue is on our side.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Confusing length handling in nrf_log_frontend.c</title><link>https://devzone.nordicsemi.com/thread/280638?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 14:07:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce0c7277-861d-4658-b836-f0767aa09b57</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Than you for posting your suggestions. I confirmed with the developers that they agree that this will make the code more readable.&lt;/p&gt;
&lt;p&gt;I have created an internal report, it will be considered for future releases.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Confusing length handling in nrf_log_frontend.c</title><link>https://devzone.nordicsemi.com/thread/280127?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 14:02:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:110fd8f5-d5d1-47ac-a216-6e426e2a5021</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nordic_2D00_suggestion.diff"&gt;devzone.nordicsemi.com/.../nordic_2D00_suggestion.diff&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To be a little more specific I attached a patch file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>