WiServer behaving strangely

Hello,

I am experiencing some strange results with the WiServer library for the Arduino Wifi. I am using a BlackWidow, which is a Duemilanove equivalent with a WiShield onboard.

My program is fairly large, and takes the value of many sensors and broadcasts them over wifi as an HTTP web server. However, I am running into some strange problems.

Inside my pageServingFunction sendMyPage, perform the usual strcmp's to determine which page to serve. If I comment all the sensor functions out and my program only performs the WiServer functions, everything works fine. However, if I use the sensor functions, then anything more than 1 if and 1 else (such as any else if's) cause the Wifi to time out, or sometimes send out "application/octet-stream" instead of the normal HTML, which if opened looks like gibberish.

I've also noticed that sometimes my program outputs more than 1 "Processing request for" to the Serial for only 1 web page request, additionally the "Server connection closed" appears a few Serial lines down, after some other sensors have been polled, almost as if my program is running out of order, or somehow using multiple threads, which should be impossible.

I have tried to figure this out for some time now, the coding looks fine but perhaps I missing something more simple?

Any suggestions are much appreciated!!

I have tried to figure this out for some time now, the coding looks fine but perhaps I missing something more simple?

Who else has reviewed the code?

String constants, as might be used in strcmp calls, occupy space in SRAM. If you have a lot of them, or a lot of small arrays, or any large arrays, you are likely running out of memory.

Strange things happen when there is not enough memory.

I am the only one working on the code, so I guess it could be a possible bug with my code but most of what I am doing is working with the pre-existing libraries so I doubt it.

This is what is sent to my web browser, it contains:

THIS IS A TEST
68.1.2
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-E À 
 À @ 

ÿ %i&Õ

?
?&q

p À @ 

ÿ %h&Õ
µ
¶

"THIS IS A TEST" is supposed to be the only text printed to HTTP, perhaps some kind of bug with the HTTP header function of WiServier?

"THIS IS A TEST" is supposed to be the only text printed to HTTP, perhaps some kind of bug with the HTTP header function of WiServier?

How do you know how many characters there are supposed to be in the string?

There was a thread a while back about the client.available() function not returning the correct number of characters under some circumstances. I don't think that a good resolution was found, but I recall that the number was always too high, by an exact amount.

Perhaps this same issue is nibbling on your posterior.

Problem solved: I changed the static text variables to PROGMEM and it works fine. Looks like I was out of SRAM.