Stackoverflow Bug?

Hey,
Ive got a Problem with this Code: /*A simple web server using an Arduino Wiznet Ethernet shield. For Arduino IDE - Pastebin.com
The Error wenn Compiling/Uploading is this: Exception in thread "Thread-143" java.lang.StackOverflowError at java.util.rege - Pastebin.com

if i change the Code to this: /*A simple web server using an Arduino Wiznet Ethernet shield. For Arduino IDE - Pastebin.com
i can upload it, but all other clients like firefox can't connect to it, its giving me an "connection interrupted" / "Verbindung Unterbrochen" (in german)

What can i do to fix this?

Thanks,
Greetz

The java error’s indicate an error in the IDE, maybe your java needs an update.

On what board are you running this code?

finally I see …String … in the code and I know this class is not the most memory efficient.

and the line starting with

client.println(" …

is only runnable on a MEGA I assume.

And a truck load of client.print() statements eating your SRAM.

"finally I see ...String ... in the code and I know this class is not the most memory efficient. "
Should i use char instead?

"On what board are you running this code?"
Its not an original arduino board, its the arduino board from here: http://www.franzis.de/elektronik/lernpakete-elektronik/franzis-lernpaket-fuer-arduino

"maybe your java needs an update."
would an java update help?

"And a truck load of client.print() statements eating your SRAM."
I used this method to check if it cant handle the long string, but if i do it like this its uploading, if i do it in one long string, it doesnt upload and give me the error i posted above.

Thanks for the answers. :wink:

Which version of the IDE are you using?

Each of the character literals in the client.print() statements is moved into SRAM before your code starts running. I haven't counted the number of characters, but you only have 2KB of SRAM, and those strings are eating a lot of it.

So would char fix it? or is there any other method to load such a big html file?, maybe switch to sdcard load the html file and then switch to the wiznet chip?

Which version of the IDE are you using?

The answer is to keep things in flash, and find a way to stop them being copied into SRAM. If you are using IDE 1.0, then there is an easy way to do that, with the F() macro. This

          client.println(F("HTTP/1.1 200 OK"));

prints the string directly from flash.

Im using the 0023 IDE, should i download the 1.0?

Im using the 0023 IDE, should i download the 1.0?

what is holding you back to try?

ok so i downloaded now the 1.0 IDE and tryed this code: http://pastebin.com/5YUzMQxX
and i still get this error: http://pastebin.com/34XGByJd

if i use this Code: http://pastebin.com/ZePNgA30
the IDE says the sketch is too big…

What could i do now to solve it?

It definitely looks like a bug in the IDE application, not the Arduino code

  • what platform do you use? mac linux PC?

Im using an PC.
This Java-tester is saying me that i have the version 1.7.0_03

Perhaps a 6000+ character string is too long.

yeah, but how could i trick it?, for example put the html file on my sd-card then read it and then display it, would that work?

Split it up and send a number of shorter lines.

I tried the code on 1.0 and 0.22 (win7/64) both failed with the exception you got, so bug confirmed. The auto formatting crashes too. There is probably a buffer overrun intern in the IDE that cannot hold strings that are too long.

The cause is two long strings. (two not one). if these two strings are removed from the code the application compiles perfectly (not tried to run it) .

Solutions:

  1. Split the strings up in shorter ones, that are client.print()-ed seperately .
    You will still have problems with the restricted memory of the UNO ==> to be solved with progmem / F()

  2. Write these strings (all html content) to an SDcard and read it when needed to send over the internet.
    imho the better solution.

i will try the second one, but how do i deactivate the wiznet chip read the html file and then activate the wiznet and send it to the client?
i know how to read the html file, how to send it to the client, but how do i deactivate the chip and then activate it?

If the wiznet chip is connected to SPI you can add a few lines to set the CS lines of the ethernet and sdcard alternating high.

something like

digitalWrite(CC_ET, LOW);
digitalWrite(CC_SD, HIGH);
string = file.readstring();

digitalWrite(CC_SD, LOW);
digitalWrite(CC_ET, HIGH);
client.println(string);

allways do the low first before setting the next to high...

Hey,
I bought a new Arduino Board so i have now 128k Memory, but my new Problem is, when i try to compile/upload this code: #include <SPI.h>#include <Ethernet.h>#include <LiquidCrystal.h>#include <SD.h - Pastebin.com
the IDE says: "sketch_apr18a.cpp: In function 'void setup()': sketch_apr18a.cpp:32:31: error: 'myfile' was not declared in this scope"

but myfile is declared?, why does it says it isn't?

Thanks guys,
Greetz

Case matters, myfile is not myFile.