Go Down

Topic: HTML Causing Arduino To Crash (Read 824 times) previous topic - next topic

dan_miles86

Hi all,

I've been working on some basic HTML pin controls as a mini project to learn Ethernet side of Arduino but I keep getting stuck....

The following lines always crash the Arduino and make it restart.

Code: [Select]
//         client.print("<form method=get>");     
         
//                                  client.print("<input type='radio' name=r2 value='1'");
//         if (digitalRead(2) == 1) client.print(" checked");
//                                  client.print("> Relay 2<br>");
         
         
//         client.print("<input type='radio' name=r value='2' checked> Two<br>");
//         client.print("<input type='radio' name=r value='3'> Three<br>");
//         client.print("</form>");


Even leaving out the 3 that make up the if statement and just using the following line does the same..

Code: [Select]
//         client.print("<input type='radio' name=r value='3'> Three<br>");



If I replace with...

Code: [Select]
         client.print("<br>");
         client.print("Test Text");
         client.print("<br>");


It works fine, just not with the form HTML.

Full code attached.

Any ideas?

PeterH

Perhaps you're running out of RAM. All those strings will be occupying RAM, and there is only a tiny amount available. Without seeing the whole sketch (hint!) or knowing what hardware you're using (hint, hint!) it's impossible to do more than guess, but that would be my guess. You avoid those strings using RAM by defining them as PROGMEM values.
I only provide help via the forum - please do not contact me for private consultancy.

Quick5pnt0

You probably need to escape the single quotes like this:

Code: [Select]
client.print("<input type=\'radio\' name=r value=\'3\'> Three<br>");

dan_miles86

Thanks both for the quick replies :)

Quick5pnt0 - No such luck does the same  =(

PeterH - You might be right, 1 line of code seems to cause a restart when I try to access the device. Whereas multiple lines of code just cause it to reboot instantaneously. I'm pretty new to this so will look up what you mean by PROGMEM tomorrow after I've got some sleep and have more patience.

PS Its an UNO and the full code is attached to the original post.

Thanks again  :)

zoomkat

Quote
PS Its an UNO and the full code is attached to the original post.


Hint: it is a PITA to download code when it can be posted in a code box.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

dan_miles86

Zoomkat - I tried but it was too long :( I could try stripping out what I few as the "unimportant" code when I get home from work.

SurferTim

Use the F() function to keep those static strings in program memory.
Code: [Select]
client.print(F("<form method=get>"));     
Do the same to the rest of those strings, and that should save you a lot of SRAM.

Go Up