Go Down

Topic: string argument to a function - memory problem with RAM (Read 144 times) previous topic - next topic

ids2001

Hello,

in my current project I have follwing problem.

I want to transmit a string argument to a function from my main loop.
The project contains at the moment about 2500 codeline and i have only 358 bytes free memory ( freeMemory () )

When I did the coding like the code here,the arduino will restart ( again and again ) after loading the new sketch. I think I must have a memory problem maybe with useing the mySoftSerial.print ( in my case Scada.print) function, because I think it is good to use a pointer to my char array ( string )
Or what are you thinking where the bug is located ??

The SendToScada("...") function is called some times in my code

Code: [Select]

void loop()
{
   //do some other work here
   sendToScada("this text should be send to a scada system");
}



void sendToScada(char* sMessageToSend)
{
  Scada.listen();
  Scada.print("V"); // Messageheader
  for(int i=0;i<strlen(sMessageToSend);i++)
      Scada.print(sMessageToSend[i]);
  Scada.print("\n");
  XBee.listen(); //set to other serial active
}
http://engineeringatnight.blogspot.co.at/

UKHeliBob

Have a look at this page http://playground.arduino.cc/Learning/Memory
As you will see it is possible to store strings in flash memory to save program space.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up