Some basic questions re: Uno + Ethernet shield

Hi all!

First, thanks in advance for any help.

  1. Can anybody out there recommend any good reading about the Uno+Ethernet shield? I'm running into very sporadic behavior even with very basic sketches/configurations. Example: I have a sketch that connects to a server every 30 seconds. My servo spits out very simple output and I know the server is responding exactly the same way every single time. Now, the Arduino sometimes fails to connect and hangs (say ever third time). Eventually, it fails to connect and retries, in which case it normally works. But it seems random, and not very reliable. Ideas? Info to read? Tips?

  2. Originally, I created a RESTful API for the data that I'm serving from my web server, but I couldn't find anything that'd make parsing an XML string or JSON/etc very easy on Arduino, so I switched to simply outputting a single line. I started with the example sketch for Ethernet, and basically am reading one character at a time. Unfortunately, the header data is part of the response. In order to get the data I want (an integer, 0-99) I need to set some sort of flag in my output so I know where to stop simply looping over characters and start recording them. So my server outputs something like !$!$:4: - when I encounter a ! character I then check if the next character is a $ and then if the next character is a ! and so fourth, until I get to the : then I start keeping the values until I hit the : character. This works, but is something of a pain and not very scalable... Is there any great way to do this that's better/cleaner/etc?

  3. Stupid question: what about ignoring header data? Is there any functionality in place that would allow me to automatically skip over header data to get to the actual response only? That would solve my problem, as I'd just need to look at the body of the response. Again, my return type is just text, and I can control my server headers to some extent.

Thanks for any help, I really appreciate it!

Some code that extracts desired data from a file supplied from a server.

//zoomkat 12-22-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;
int x=0;
char lf=10;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
byte server[] = { 140, 90, 238, 27 }; // NOAA

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();
  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /data/5day2/44013_5day.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    //Serial.print(c);  // uncomment to see raw feed
    if (c==lf) x=(x+1);
    if (x==14) readString += c;
    //readString += c;
  }

  if (!client.connected()) {
     client.stop();

    Serial.println("Current data row:" );
    Serial.print(readString);
    Serial.println();
    readString1 = (readString.substring(41,43));
    Serial.println();
    Serial.print("DPD sec: ");
    Serial.println(readString1);
    Serial.println("done");

    for(;;);

    }
 }