<?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>Exception when using printk with CONFIG_CBPRINTF_FP_SUPPORT=y enabled in NCS 1.4.99-dev</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70562/exception-when-using-printk-with-config_cbprintf_fp_support-y-enabled-in-ncs-1-4-99-dev</link><description>I&amp;#39;m trying to port some code from FreeRTOS to Zephyr using a Nordic nRF52840. (I&amp;#39;ve used FreeRTOS for quite a while, but am a novice with Zephyr.) 
 I&amp;#39;m using k_poll() (in Zephyr) to implement the same functionality as xTaskNotifyWait (in FreeRTOS). I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Jan 2021 19:48:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70562/exception-when-using-printk-with-config_cbprintf_fp_support-y-enabled-in-ncs-1-4-99-dev" /><item><title>RE: Exception when using printk with CONFIG_CBPRINTF_FP_SUPPORT=y enabled in NCS 1.4.99-dev</title><link>https://devzone.nordicsemi.com/thread/289873?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 19:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e55f6cf-2bc7-4741-902d-d41206b96a90</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;This may have been &amp;quot;pilot error&amp;quot;.&amp;nbsp; &amp;nbsp;The original format for the sprintf() used &amp;quot;%5.2f&amp;quot; as the floating point specifier for each of the two float values being reported.&lt;/p&gt;
&lt;p&gt;When the sprintf() failed, I removed the &amp;quot;5.2&amp;quot; thinking that perhaps there was a problem with the specification.&amp;nbsp; &amp;nbsp;However the destination for the result had been sized assuming a &amp;quot;shorter&amp;quot; result.&amp;nbsp; &amp;nbsp;So removing the &amp;quot;5.2&amp;quot; made the resulting string longer and (I think) overran the supplied buffer.&amp;nbsp; &amp;nbsp; I think this caused the issue in &amp;quot;str_out()&amp;quot;.&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Exception when using printk with CONFIG_CBPRINTF_FP_SUPPORT=y enabled in NCS 1.4.99-dev</title><link>https://devzone.nordicsemi.com/thread/289808?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 14:47:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c684d06a-3df4-4d40-a9ba-25e9648fdf1e</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Here is a snippet of code where sprintf is used:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    } else if(tempEventConditions[0].signal-&amp;gt;result == TEMP_EVENT_DATA) {
      // Data transfer completed; process the data and send it
      int16_t tempCRaw = ((readBuf[0] &amp;lt;&amp;lt; 8) | readBuf[1]) / 32;
      float tempC = (float)tempCRaw * 0.125;
      float tempF = (tempC * 1.8) + 32;
      // Put data into appropriate characteristic (rotate through 4)
      tempData[tempCharCntr].tempAmbient=           tempCRaw;
      tempData[tempCharCntr].tempObjectKelvin=      tempCRaw;
      tempData[tempCharCntr].tempObjectCelsius=     tempC;
      tempData[tempCharCntr].tempObjectFahrenheit=  tempF;
      //char strBuf[30];
      sprintf(tempData[tempCharCntr].tempString,&amp;quot;Temp F: %f   Temp C: %f\n&amp;quot;,tempF,tempC);
//printk(&amp;quot;%s&amp;quot;,tempData[tempCharCntr].tempString);
      // Populate the queue item
      tempQueueItem[tempCharCntr].fifo_reserved     = NULL;
      tempQueueItem[tempCharCntr].conn              = bleCurrentConnection;
      tempQueueItem[tempCharCntr].characteristic    = (struct bt_gatt_attr *)&amp;amp;tempService.attrs[5];
      tempQueueItem[tempCharCntr].len               = sizeof(tempDataCharacteristic);
      tempQueueItem[tempCharCntr].data              = (void *)&amp;amp;tempData[tempCharCntr];
      // Send the queue item via the FIFO to the send thread
      k_fifo_put(&amp;amp;notifyQueue,&amp;amp;tempQueueItem[tempCharCntr]);
      // Update tempCharCntr
      tempCharCntr= (tempCharCntr + 1) &amp;amp; NUM_TEMP_BUFFERS_MASK;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As mentioned earlier, this worked in NCS 1.4.0, but I couldn&amp;#39;t get 1.4.1 or 1.4.2 to compile due to the MACRO expansion issue shown in the original post.&lt;/p&gt;
&lt;p&gt;When 1.4.99-dev is used, sprintf doesn&amp;#39;t recognize &amp;quot;%f&amp;quot; as a conversion token (so &amp;quot;%f&amp;quot; is output literally).&amp;nbsp; &amp;nbsp; The CONFIG:&amp;nbsp;&lt;span&gt;CONFIG_CBPRINTF_FP_SUPPORT&amp;nbsp;seems to be needed for this to be overcome, but causes printk (even earlier printk statements that have nothing to do with floating point) to fail in the function str_out().&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Exception when using printk with CONFIG_CBPRINTF_FP_SUPPORT=y enabled in NCS 1.4.99-dev</title><link>https://devzone.nordicsemi.com/thread/289713?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 12:34:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddda8ac9-6369-4b49-9829-77fb312b1d65</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hello Ed Hepler.&lt;/p&gt;
&lt;p&gt;Could you please attach the code snippet that uses sprintf using %f. I would quickly test to see why it fails in the latest NCS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>