AnsweredAssumed Answered

strstr failure?

Question asked by Ariela Blumer on Apr 18, 2016
Latest reply on Apr 18, 2016 by Marek Trmac

Hi,

 

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.

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.

Please find below the received buffer which was printed to log when a response was expected but driver failed to detect it.

 

buffer size is 106

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

 

The string I'm looking for is in the middle of the second line:

65 84 43 87 82 83 83 73 61 63 13 13 10 45 50 50 = AT+WRSSI=?

 

and the code is:

 

// parse the response at set an integer w/ the result

p_rssi_response = strstr((const char*)cmdRspBuff,(const char*)"AT+WRSSI=?");

 

  // if we got a valid response, parse it and set a decimal result on global DB

  // otherwise, rssi is set to 0, indicating the vale is invalid.

  if (NULL != p_rssi_response)

  {

       // Expected result is AT+WRSSI=?\r\r\n-63\r\nOK\r\n

       // Jump over the command and point to the response

       p_rssi_response += 14;

 

       for(i=0;i<2;i++)

       {

            rssi = (rssi* 10) + (p_rssi_response[i]-'0');

       }

  }

  GET_CUSTOM_CXT(priv)->rssi = -rssi;

  GS_DEBUG_PRINT(1, "RSSI %d p_rssi_response 0x%x\n", rssi, p_rssi_response);

 

Any idea what might be wrong here?

 

Thanks,

Ariela

Outcomes