Hi,
Thanks for taking the time to update us on this--it really makes a difference when people let everyone know how they solved their problems!
luwii wrote:The Serial.println caused a delay which made the code work.
Yeah, I've been caught by this type of thing in both directions--either a delay making code work or making it not work, which is why "print" debugging is not the height of debugging tools.
So this suggests the junk characters you were seeing were the ASCII character 255 (-1 as a byte value) which might appear as a block or a "y" with two dots above it or: "ÿ" or similar. It can be helpful when debugging single characters to display both the character and the value separately.
The web server code has a (client.connected() && client.available()) check, and then within that block a c=client.read(); It's important to check that client .read() does not return -1. in a loop like this. If it does, just wait a little bit and try again. Couple of milliseconds should do the trick.
This is web server code that you've written yourself not based on one of the Ethernet or WiFly examples? The approach used in these examples to avoid the situation you encountered is to use something like this:
Code: Select allwhile (client.connected()) {
if (client.available()) {
char c = client.read();
// Handle just one character here.
}
}
If you check to see how many characters are available (the actual value returned from the available() call) then you can handle multiple characters at one time. If available() evaluates as true then you should never get -1 from a single call to read() so you shouldn't need to check for it within a loop of this style.
Thanks again for letting us know the solution--all the best for the rest of your project.
--Philip;