Pages: [1]   Go Down
Author Topic: HTML Causing Arduino To Crash  (Read 762 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
//         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:
//         client.print("<input type='radio' name=r value='3'> Three<br>");



If I replace with...

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

It works fine, just not with the form HTML.

Full code attached.

Any ideas?

* webcontol_dhcp_full_0_4.ino (10.69 KB - downloaded 14 times.)
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You probably need to escape the single quotes like this:

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


Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks both for the quick replies smiley

Quick5pnt0 - No such luck does the same  smiley-cry

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  smiley
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9750
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 152
Posts: 6181
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: