<?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 strstr failure? in Kinetis Design Studio</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511424#M6709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a platform w/ K66 as MCU and a GS2K device for WiFi connectiovity. Data, events and responses to commands are received in the K66 via UART. A driver parses the received buffer and forwards to RTCS/application.&lt;/P&gt;&lt;P&gt;It happens that the WiFi driver fails to identify events or responds. I added some debug info and it appears that strstr fails to detect strings in the received buffer.&lt;/P&gt;&lt;P&gt;Please find below the received buffer which was printed to log when a response was expected but driver failed to detect it.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;buffer size is 106&lt;/P&gt;&lt;P&gt;10 13 10 58 106 49 188 67 1 16 0 1 0 0 0 0 0 0 32 70 72 70 65 69 66 69 69 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 65 65 0 0 32 0 1 65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 13 10 79 75 13 10 10 13 10 65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 13 10 79 75 13 10 10 13 10&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The string I'm looking for is in the middle of the second line:&lt;/P&gt;&lt;P&gt;65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 = AT+WRSSI=?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the code is: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// parse the response at set an integer w/ the result&lt;/P&gt;&lt;P&gt; p_rssi_response = strstr((const char*)cmdRspBuff,(const char*)"AT+WRSSI=?");&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // if we got a valid response, parse it and set a decimal result on global DB&lt;/P&gt;&lt;P&gt;&amp;nbsp; // otherwise, rssi is set to 0, indicating the vale is invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (NULL != p_rssi_response)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Expected result is AT+WRSSI=?\r\r\n-63\r\nOK\r\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Jump over the command and point to the response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_rssi_response += 14;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;2;i++)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rssi = (rssi* 10) + (p_rssi_response[i]-'0');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; GET_CUSTOM_CXT(priv)-&amp;gt;rssi = -rssi;&lt;/P&gt;&lt;P&gt;&amp;nbsp; GS_DEBUG_PRINT(1, "RSSI %d p_rssi_response 0x%x\n", rssi, p_rssi_response);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what might be wrong here?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ariela&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Apr 2016 11:25:57 GMT</pubDate>
    <dc:creator>arielablumer</dc:creator>
    <dc:date>2016-04-18T11:25:57Z</dc:date>
    <item>
      <title>strstr failure?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511424#M6709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a platform w/ K66 as MCU and a GS2K device for WiFi connectiovity. Data, events and responses to commands are received in the K66 via UART. A driver parses the received buffer and forwards to RTCS/application.&lt;/P&gt;&lt;P&gt;It happens that the WiFi driver fails to identify events or responds. I added some debug info and it appears that strstr fails to detect strings in the received buffer.&lt;/P&gt;&lt;P&gt;Please find below the received buffer which was printed to log when a response was expected but driver failed to detect it.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;buffer size is 106&lt;/P&gt;&lt;P&gt;10 13 10 58 106 49 188 67 1 16 0 1 0 0 0 0 0 0 32 70 72 70 65 69 66 69 69 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 67 65 65 65 0 0 32 0 1 65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 13 10 79 75 13 10 10 13 10 65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 13 10 79 75 13 10 10 13 10&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The string I'm looking for is in the middle of the second line:&lt;/P&gt;&lt;P&gt;65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 = AT+WRSSI=?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the code is: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// parse the response at set an integer w/ the result&lt;/P&gt;&lt;P&gt; p_rssi_response = strstr((const char*)cmdRspBuff,(const char*)"AT+WRSSI=?");&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // if we got a valid response, parse it and set a decimal result on global DB&lt;/P&gt;&lt;P&gt;&amp;nbsp; // otherwise, rssi is set to 0, indicating the vale is invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (NULL != p_rssi_response)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Expected result is AT+WRSSI=?\r\r\n-63\r\nOK\r\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Jump over the command and point to the response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_rssi_response += 14;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;2;i++)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rssi = (rssi* 10) + (p_rssi_response[i]-'0');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; GET_CUSTOM_CXT(priv)-&amp;gt;rssi = -rssi;&lt;/P&gt;&lt;P&gt;&amp;nbsp; GS_DEBUG_PRINT(1, "RSSI %d p_rssi_response 0x%x\n", rssi, p_rssi_response);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what might be wrong here?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ariela&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 11:25:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511424#M6709</guid>
      <dc:creator>arielablumer</dc:creator>
      <dc:date>2016-04-18T11:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: strstr failure?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511425#M6710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note that strstr sometimes succeeds, when it does the string I'm looking for resides at the begining of the buffer, right after carrige retrun and line feed (13 &amp;amp; 10).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 13:20:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511425#M6710</guid>
      <dc:creator>arielablumer</dc:creator>
      <dc:date>2016-04-18T13:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: strstr failure?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511426#M6711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ariela,&lt;/P&gt;&lt;P&gt;in C language, strings are terminated using zero char(0) and function strstr() does not search beyond the end of string. &lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2016 06:12:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/strstr-failure/m-p/511426#M6711</guid>
      <dc:creator>MarekTrmac</dc:creator>
      <dc:date>2016-04-19T06:12:41Z</dc:date>
    </item>
  </channel>
</rss>

