Debugging tools for Arduino 1.0 ?

I've noticed that my OpenKontrolGateway with emon NanodeRF sketch seems to lockup after several hours.

Is there some sort of debugging tool available to simulate the sketch and monitor memory usage and variables while running the sketch ?

I come from the Turbo Pascal era and debugging a running program these days was a peace of cake in the IDE ;-)

 

TrystanLea's picture

Re: Debugging tools for Arduino 1.0 ?

That would be a nice feature wouldn't it, but Im afraid I dont think it exists. I think the hardware differences with different shields etc would provide the largest obstacle? It would have to simulate an ethernet shield and the ethercard library, http request to the server etc. 

jstoaks's picture

Re: Debugging tools for Arduino 1.0 ?

 

Adafruit has some info on reading available sram.

  PgmPrint("Free RAM: ");
  Serial.println(FreeRam());

Search for adafruit SD web browse, which shows the Wiznet 5100 ethernet  and functions.

I have found that the ethernet library and functions take up alot of sram, and the more client print statements you add the more memory is used. Just like Serial.print statements us up memory.

​Best regards

​J

prensel's picture

Re: Debugging tools for Arduino 1.0 ?

I think the OKG was running out of RAM and crashed because I had some Serial.print lines for debugging.

Did add a simple check for free memory and it showed 13 bytes free..

Got rid of all the serial.print lines and ended up with 158 bytes free so uploaded the sketch onto (another) NanodRF and its running for the last 24 hours or so.

Havent tried that sketch on the OKG yet but will do that and expect it will work like the nanoderf does.

As the  OKG has an additional 32K SRAM, i'm still not sure how to use that extra as RAM ?

I'd like to add to the existing nanodeRF sketch a simple webserver and local (as on the SDcard) logging tool so you can view these locally (by means of an Iphone or something) without having (or even besides) to setup a Pachube or emonCMS account.

But with 158byte free ram this is impossible so i need to address the extra 32K SRAM for it but how ?

BTW i'm not using a Wiznet but ENC Ethernet chip on both the OKG and the NanodeRF so the Adafruit freeram() doesnt work i believe so i used this:

 

/**********************************************************************************************************************
// SETUP_memory
//**********************************************************************************************************************
void setup_memory() {
  int result = memoryTest();
  Serial.print("Memory:");
  Serial.println(result,DEC);
}

// this function will return the number of bytes currently free in RAM
int memoryTest() {
  int byteCounter = 0; // initialize a counter
  byte *byteArray; // create a pointer to a byte array
  // More on pointers here: http://en.wikipedia.org/wiki/Pointer#C_pointers

  // use the malloc function to repeatedly attempt allocating a certain number of bytes to memory
  // More on malloc here: http://en.wikipedia.org/wiki/Malloc
  while ( (byteArray = (byte*) malloc (byteCounter * sizeof(byte))) != NULL ) {
    byteCounter++; // if allocation was successful, then up the count for the next try
    free(byteArray); // free memory after allocating it
  }
 
  free(byteArray); // also free memory after the function finishes
  return byteCounter; // send back the highest number of bytes successfully allocated
}
 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.