<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: _putstr in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535538#M16429</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the K66 and a simple example of the problem would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt; buf&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;30&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; txt1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Some really long text obtained from somewhere but I only have space for a small amount"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t numChars &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;sprintf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; buf&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Output: %.18s..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; txt1 &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;UART_DRV_SendDataBlocking&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; uartCom4_IDX&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;buf&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numChars&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;10&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to sprintf it should return the number of characters generated so the above should return 29. But it actually returns 97 (I think, but I've not run it)&amp;nbsp;as it takes the full length of txt1 instead of the 18 characters it actually copied to the buffer.&lt;/P&gt;&lt;P&gt;I know in the example I could just use strlen( buf ) but my real code is doing a lot more than the example and it is filling&amp;nbsp;a buffer from multiple sources so it is critical that the number of characters placed in the buffer is accurate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adrian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2016 08:46:46 GMT</pubDate>
    <dc:creator>adyr</dc:creator>
    <dc:date>2016-09-14T08:46:46Z</dc:date>
    <item>
      <title>_putstr</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535536#M16427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is the _putstr function in print_prv.c correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using KSDK 1.3 + MQX and I am calling:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14694519513165935 jive_text_macro" data-renderedposition="160_50_798_16" jivemacro_uid="_14694519513165935"&gt;&lt;P&gt;numChars = sprintf ("%s%s%.19s", data1, data2, data3 );&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where data3 is a string containing 48 characters. The value returned is the length of the 3 source strings even though it has only inserted 19 of the 48 characters from data3.&lt;/P&gt;&lt;P&gt;When I look at _putstr it seems to set compare = true after inserting the required number of characters so the count continues to increase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should this not set continue = false to abort the loop so the returned count is the number of characters actually inserted?&lt;/P&gt;&lt;P&gt;Also the comments for _putstr state the default value for max_count is 0 (unlimited size), but this would results in no characters being output. Is it the comment or the code that is wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Adrian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2016 13:22:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535536#M16427</guid>
      <dc:creator>adyr</dc:creator>
      <dc:date>2016-07-25T13:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: _putstr</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535537#M16428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please share the code and let me know the device you are using, in order to reproduce this issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Soledad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2016 20:48:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535537#M16428</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2016-09-06T20:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: _putstr</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535538#M16429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the K66 and a simple example of the problem would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt; buf&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;30&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; txt1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Some really long text obtained from somewhere but I only have space for a small amount"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t numChars &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;sprintf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; buf&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Output: %.18s..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; txt1 &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;UART_DRV_SendDataBlocking&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; uartCom4_IDX&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;buf&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numChars&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;10&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to sprintf it should return the number of characters generated so the above should return 29. But it actually returns 97 (I think, but I've not run it)&amp;nbsp;as it takes the full length of txt1 instead of the 18 characters it actually copied to the buffer.&lt;/P&gt;&lt;P&gt;I know in the example I could just use strlen( buf ) but my real code is doing a lot more than the example and it is filling&amp;nbsp;a buffer from multiple sources so it is critical that the number of characters placed in the buffer is accurate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adrian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 08:46:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535538#M16429</guid>
      <dc:creator>adyr</dc:creator>
      <dc:date>2016-09-14T08:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: _putstr</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535539#M16430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adrian,&lt;/P&gt;&lt;P&gt;Please try following:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; uint32_t numChars = sprintf( buf, "Output: %-18.18s...", txt1 );&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 15:31:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/putstr/m-p/535539#M16430</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-09-14T15:31:31Z</dc:date>
    </item>
  </channel>
</rss>

