9 years, 7 months ago.  This question has been closed. Reason: Off Topic

sscanf not returning expected data

Here's a snip of code that I used from your library.

sscanf snip

int numMatched = sscanf(data,"+IPD,%d,%d:%n", &linkID, &bytesRecv, &ipdLen);

Couldn't get the data out correctly so changed to this, but still not working, no data, only zero's.

my sscanf snip

  int linkID,ipdLen;
  char type[8];

  int numMatched = sscanf(buf,"+IPD,%d,%d:%s", &linkID, &ipdLen, type);
   
   pc.printf("IPD Data:\n LinkID= %d,\n IPD Header Len= %d \n Type= %s\r\n", linkID, ipdLen, type);

  // I need the link Id "0", IPD length "247" and type "GET" from the following part of the data in the 'buf'   

  //+IPD,0,247:GET / HTTP/1.1


The buf has been set to 1024 characters, should be plenty of space.

I did try your example but the ESP serial would not work, so did something else with interrupt serial that works, sending web pages, but I need to get this IPD data to check for GET or POST. Any suggestions?

Where's that Minion?

Question relating to:

ESP8266 WiFi Module Web Server library ESP8266

Try making a simple test program with just pc serial, and manually send that string and see if it works. If it does work, then you aren't getting the string you think you are getting.

Then I don't know if scanf possibly requires a whitespace character after the number. You can also try that with that test program.

posted by Erik - 10 Feb 2015

I was just about to do that when I saw your suggestion. It did work in a simple test program, so I removed the whitespace (8 \n characters) that the ESP places before the +IPD as you suggested in second paragraph which has now cured the issue.

So you have in fact answered my question (but I can't hit an answer button).

Many thanks

Paul

posted by Paul Staron 10 Feb 2015

Hi Paul

Just checking that you have in fact gotten it working? Can I close this question?

posted by Sebastian Schocke 08 Mar 2015