Pages: [1]   Go Down
Author Topic: string argument to a function - memory problem with RAM  (Read 112 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
}
Logged


East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 89
Posts: 3480
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Jump to: