Parsing large strings


hi,
i writing program use wifi data string, parse , set external leds result.  i'm working on parsing section. 

i attempting put in sample string parsing right.  rather long (1185 chars).  causing ide crash when compiling.  i've tried taking out single quotes, faq says strange " ' \ combinations can cause no avail.  ide crashes when attempting auto-format code.

there ~2kb limit on data in sram, i've tried using progmem, still crashes.

i around needing full string parsing read network i'm worried buffer overflow if data not read fast enough.

i'm using wifi shield, mega 2560 , v1.0.3 of ide (so compatible wifi).

if has suggestions or relevant experience i'd appreciate them.
the code
code: [select]

#include <avr/pgmspace.h>
/*
  string substring()

examples of how use substring in string

created 27 july 2010,
modified 2 apr 2012
zach eveland

http://arduino.cc/en/tutorial/stringsubstring

example code in public domain.
*/

void setup() {
  // open serial communications , wait port open:
  serial.begin(9600);
  while (!serial) {
    ; // wait serial port connect. needed leonardo only
  }

  // send intro:
  serial.println("\n\nstring  substring():");
  serial.println();
}

void loop() {
  // set string:
  //progmem derective put strin in flash mem
   progmem string string = "<td >wind %</td><td style='background-color: rgb(36, 184, 36)'>24%</td><td style='background-color: rgb(36, 184, 36)'>24%</td><td style='background-color: rgb(36, 184, 36)'>25%</td><td style='background-color: rgb(36, 184, 36)'>25%</td><td style='background-color: rgb(36, 184, 36)'>26%</td><td style='background-color: rgb(36, 184, 36)'>26%</td><td style='background-color: rgb(36, 184, 36)'>23%</td><td style='background-color: #ffcc32'>18%</td><td style='background-color: #ffcc32'>14%</td><td style='background-color: #ffcc32'>13%</td><td style='background-color: #ffcc32'>13%</td><td style='background-color: #ffcc32'>13%</td><td style='background-color: #ffcc32'>14%</td><td style='background-color: #ffcc32'>15%</td><td style='background-color: #ffcc32'>15%</td><td style='background-color: #ffcc32'>15%</td><td style='background-color: #ffcc32'>15%</td><td style='background-color: #ffcc32'>14%</td><td style='background-color: #ffcc32'>13%</td><td style='background-color: #ffcc32'>12%</td><td style='background-color: #ffcc32'>11%</td><td style='background-color: #ffcc32'>11%</td><td style='background-color: #ffcc32'>13%</td><td style='background-color: #ffcc32'>12%</td>";
  serial.println(string);
  int one=0,two=0;
  boolean runloop=true;
  //read first seed loop
  one=string.indexof(">",string.indexof("</td>")+5);//get time's start (end tag of colour)
  if(one<0||two<0)
  {
    runloop=false;
  }
  one=one+1;//move start of number
  two=string.indexof("</td>",one);//get time's end tag
  if(one<0||two<0)
  {
    runloop=false;
  }

  while(runloop)
  {//while percents left
    string time=string.substring(one,two);
    serial.println(time);
    one=string.indexof(">",two+5);//get time's start (end tag of colour)
    if(one<0||two<0)
    {
      runloop=false;
    }
    one=one+1;//move start of number
    two=string.indexof("</td>",one);//get time's end tag
    if(one<0||two<0)
    {
      runloop=false;
    } 
    //serial.print(one);
    //serial.println(" = one");
    //serial.print(two);
    //serial.println(" = two");
  }
  // nothing while true:
  while(true);
}




the error message wouldn't fit in last post.  of here, verbose forum's character limits
code: [select]

exception in thread "thread-6" java.lang.stackoverflowerror
at java.util.regex.pattern$loop.match(pattern.java:4275)
at java.util.regex.pattern$grouptail.match(pattern.java:4227)
at java.util.regex.pattern$branchconn.match(pattern.java:4078)
at java.util.regex.pattern$charproperty.match(pattern.java:3345)
at java.util.regex.pattern$branch.match(pattern.java:4114)
at java.util.regex.pattern$grouphead.match(pattern.java:4168)






Arduino Forum > Using Arduino > Programming Questions > Parsing large strings


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support