Go Down

Topic: problem with loading when one more line is added to sketch (Read 1 time) previous topic - next topic

waltsailing


Hi,

I have been writing a sketch that runs a small web server from the arduino uno.  This seems to work just great, except, without any warnings or other indications, the program seems to suffer from some sort of memory use issue during upload if I try to add in just one more line of code.  The overall program size is around 14K, out of a max of 32k.  The additional code should not be using up the limited SRAM, but maybe it is. 

In the program there are a number of lines that use client.print to serve up some HTML.  An example of them is shown below.  If I don't comment out any one of these four working lines of good code the program compiles, and then uploads, but rather than serving up the web page, it shoots fast jibberish out the serial monitor port back to the PC, rather than the expected network activity.  It doesn't matter which line is commented out. No errors when compiling, no errors when uploading.  That is the puzzle, which is leading me to think it is a memory issue, and since it is less than the flash available, its likely SRAM.  They all work fine provided that they are all not in the sketch at the same time. 

So, here are some simple questions,

1.  How do I figure out the memory utilization for the SRAM?  Is there a memory map file being stored some place?  Is there an assembly listing file available to aid in debug?

2.  Are the strings in the client.print, being stored in SRAM or are they being loaded from flash.  They are constants, so i would have expected the underlying code to use a pointer to the flash, however it is possible that it is storing these in SRAM, all at once, rather than bringing them one at at time when the line of code is actually being executed.

3.  If I am running out of SRAM, is there any easy way to find out?  The monitor goes out to lunch when I uncoment any of the additional lines.

4.  is there any way to direct the ARduino to force storage of constants in flash, so that the memory can be better managed, or at least understood?

5.  The program also uses an X10firecracker library and its associated lower level .h files, such as wiring.h (Not wire.h). 

Suggestions on how to resolve and debug this would be great.  A snipet of the issue is below.

Thank You,
Walt,

  client.println("<FORM METHOD='LINK' ACTION='http://192.168.1.177/XSomething_else\r'><INPUT TYPE='submit' VALUE='Turn on the light'></FORM>  ");
           client.println("<FORM METHOD='LINK' ACTION='http://192.168.1.177/Ytry_this_one\r'><INPUT TYPE='submit' VALUE='Light on dim it up down and Light off'></FORM>  ");
  //        client.println("<FORM METHOD='LINK' ACTION='http://192.168.1.177/Z\r'><INPUT TYPE='submit' VALUE='Light off'></FORM>  ");
       client.println("<FORM METHOD='LINK' ACTION='http://192.168.1.177/ZSomething_else\r'><INPUT TYPE='submit' VALUE='Turn off the light'></FORM>  ");   


eried

Quote
3.  If I am running out of SRAM, is there any easy way to find out?  The monitor goes out to lunch when I uncoment any of the additional lines.


Check http://arduino.cc/forum/index.php/topic,118440.0.html
My website: http://ried.cl

dxw00d

Quote
is there any way to direct the ARduino to force storage of constants in flash, so that the memory can be better managed, or at least understood?


Try using the F() macro. It keeps character literals in flash.

Code: [Select]
  client.println(F("<FORM METHOD='LINK' ACTION='http://192.168.1.177/XSomething_else\r'><INPUT TYPE='submit' VALUE='Turn on the light'></FORM>  "));
           client.println(F("<FORM METHOD='LINK' ACTION='http://192.168.1.177/Ytry_this_one\r'><INPUT TYPE='submit' VALUE='Light on dim it up down and Light off'></FORM>  "));
  //        client.println(F("<FORM METHOD='LINK' ACTION='http://192.168.1.177/Z\r'><INPUT TYPE='submit' VALUE='Light off'></FORM>  "));
       client.println(F("<FORM METHOD='LINK' ACTION='http://192.168.1.177/ZSomething_else\r'><INPUT TYPE='submit' VALUE='Turn off the light'></FORM>  "));

PaulS

It might also be a lot easier to create one form with multiple buttons than to create multiple forms with one button each.

waltsailing

Thanks for the F(...string/litteral...) answer which put this in flash.  That cleared up the problem  I have since looked at the documentation and can not find any reference to this.  Maybe I am missing out on some of the documentation.  Where would I have found this?

I will look into the HTML multiple forms/single forms, great suggestion..

Thank You,
Walt,

Go Up