<?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>Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/122299/trying-to-parse-nmea-with-double-and-strtod</link><description>Hi, 
 I&amp;#39;m trying to build nmea parser, so I have a functionc hecking all nmea sentences and trying to get double value, but I always go bad double value. For example here what I do for VTG sentence 
 
 str is defined like this 
 And here is my terminal</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Jun 2025 12:09:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/122299/trying-to-parse-nmea-with-double-and-strtod" /><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/540328?ContentTypeID=1</link><pubDate>Tue, 24 Jun 2025 12:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a33d9a4-3284-404d-aa33-4154402a8d14</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;So you get a build error when you try to build with CONFIG_FPU=y? What SDK version is that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/540178?ContentTypeID=1</link><pubDate>Mon, 23 Jun 2025 10:43:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e466d64-c17f-41fd-8b68-90df2c03d9fb</guid><dc:creator>simon884</dc:creator><description>&lt;p&gt;Yes sorry typo issue&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/540011?ContentTypeID=1</link><pubDate>Fri, 20 Jun 2025 11:27:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfd7ec33-db4b-4e13-86af-e57696b25242</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;What is&amp;nbsp;CONFIG_FU? Did you mean CONFIG_FPU?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/539821?ContentTypeID=1</link><pubDate>Thu, 19 Jun 2025 07:51:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef714083-d802-4bd3-9d6d-873fd30998b2</guid><dc:creator>simon884</dc:creator><description>&lt;p&gt;Ok thanks, just a question, if I try to enable CONFIG_FU I got an error when I&amp;#39;m trying to build&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;INVALID CONFIG: ( CONFIG_TFM_ENABLE_FP OR CONFIG_TFM_ENABLE_MVE OR
CONFIG_TFM_ENABLE_MVE_FP ) AND NOT CONFIG_TFM_ENABLE_CP10CP11&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/539681?ContentTypeID=1</link><pubDate>Wed, 18 Jun 2025 10:34:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38eacc16-418e-4da0-b0b4-77d9c2dd3126</guid><dc:creator>Hakon</dc:creator><description>[quote user="simon884"]should I add to enable FPU for float also ?[/quote]
&lt;p&gt;CONFIG_FPU should be enabled if you want to use and print floating point numbers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/539587?ContentTypeID=1</link><pubDate>Tue, 17 Jun 2025 15:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f000cf3-1dcc-4b2d-847c-98deb9d70ced</guid><dc:creator>simon884</dc:creator><description>&lt;p&gt;No I can use float, but for example if instead of strtod I use strtof I have the same result for example:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if ((strcmp(&amp;amp;field[0][3], &amp;quot;VTG&amp;quot;) == 0) &amp;amp;&amp;amp; (f &amp;gt; 8)) {

      LOG_INF(&amp;quot;Check string for strtod: &amp;#39;%s&amp;#39;&amp;quot;, field[5]);
      for (int i = 0; i &amp;lt; strlen(field[5]); i++) {
          LOG_INF(&amp;quot;field[5][%d] = 0x%02x&amp;quot;, i, field[5][i]);
      }


      char tmp_kn[16] = {0};
      char tmp_kmh[16] = {0};
      strncpy(tmp_kn, field[5], sizeof(tmp_kn) - 1);  
      strncpy(tmp_kmh, field[7], sizeof(tmp_kmh) - 1);

      float ground_speed_kn = strtof(tmp_kn, NULL);
      float ground_speed_kmh = strtof(tmp_kmh, NULL);

      snprintf(str, sizeof(str), &amp;quot;speed knt : %.4f, speed kmh : %.4f&amp;quot;, ground_speed_kn, ground_speed_kmh);
      LOG_INF(&amp;quot;VTG %s&amp;quot;, str);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I got in my terminal:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;inf&amp;gt; nmea_parser: #0 : $GNVTG
&amp;lt;inf&amp;gt; nmea_parser: #1 : 
&amp;lt;inf&amp;gt; nmea_parser: #2 : T
&amp;lt;inf&amp;gt; nmea_parser: #3 : 
&amp;lt;inf&amp;gt; nmea_parser: #4 : M
&amp;lt;inf&amp;gt; nmea_parser: #5 : 0.179
&amp;lt;inf&amp;gt; nmea_parser: #6 : N
&amp;lt;inf&amp;gt; nmea_parser: #7 : 0.331
&amp;lt;inf&amp;gt; nmea_parser: #8 : K
&amp;lt;inf&amp;gt; nmea_parser: #9 : A
&amp;lt;inf&amp;gt; nmea_parser: Check string for strtod: &amp;#39;0.179&amp;#39;
&amp;lt;inf&amp;gt; nmea_parser: field[5][0] = 0x30
&amp;lt;inf&amp;gt; nmea_parser: field[5][1] = 0x2e
&amp;lt;inf&amp;gt; nmea_parser: field[5][2] = 0x31
&amp;lt;inf&amp;gt; nmea_parser: field[5][3] = 0x37
&amp;lt;inf&amp;gt; nmea_parser: field[5][4] = 0x39
&amp;lt;inf&amp;gt; nmea_parser: VTG speed knt : 1043811264.0000, speed kmh : 1051293888.0000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So my nmea sentece seems to be good, my value also, but when i&amp;#39;m try to print I got bad value, should I add to enable FPU for float also ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: If I use sscanf instead of strtof everything works well...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to parse nmea with double and strtod</title><link>https://devzone.nordicsemi.com/thread/539483?ContentTypeID=1</link><pubDate>Tue, 17 Jun 2025 07:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ea365af-73ce-4831-98ba-d04e421abf9c</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;is CONFIG_FPU=y enabled in your application? Also, double values are not supported in hardware, but are emulated. Is there any specific reason why you don&amp;#39;t just use regular float?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>