I will post some code as soon as possible.
I use a Arduino Mega 1280 so should have some more RAM.
Can I determine how much RAM is used during a sketch is running?
I would like to be more precise of course but my research shows that I can't force the reset by sending a huge message or with lots of special characters so it's kinda random....
while(Serial1.available() > 0){
if(unlock_sms==0){
bufferReadGSM[0]=Serial1.read();
if(debug > 1)
Serial.print(bufferReadGSM[0]);
if(bufferReadGSM[0]=='\n' || bufferReadGSM[0]=='*' || bufferReadGSM[0] == '+'){
unlock_sms=1;
}
}
else{
bufferReadGSM[counter]=Serial1.read();
if(debug > 1)
Serial.print(bufferReadGSM[counter]);
if(bufferReadGSM[counter] == '\r'){
unlock_sms=0;
if (strncmp(bufferReadGSM, "*121*",5) == 0){
char *parseptr_read = bufferReadGSM+5;
int cou = 0;
int value = int(parseptr_read[0])-48;
switch (value){
case 1:
sms_senden = 1;
break;
case 2:
SmsMeldungOff = 1;
if(debug > 0)
Serial.println("-> SMS senden werden abgestellt");
break;
case 3:
GSMoffStart = 1;
if(debug > 0)
Serial.println("-> GSM wird abgestllt, vor dem Start");
break;
case 4:
wichtigeVariablen = 1;
sms_senden = 1;
if(debug > 0)
Serial.println("-> Wichtige variablen werden gesendet");
break;
}
}
if (strncmp(bufferReadGSM, "Call Ready",10) == 0) {
Serial.println("-> GSM Ready!");
}
if (strncmp(bufferReadGSM, "0",1) == 0){
if(debug > 0)
Serial.println("-> OK");
}
if (strncmp(bufferReadGSM, "+CRING:",7) == 0 && calling < 1){
if(debug > 0)
Serial.println("-> ding dong");
}
if (strncmp(bufferReadGSM, "3",1) == 0){
Serial.println("-> NO CARRIER");
calling = 0;
}
if (strncmp(bufferReadGSM, "4",1) == 0){
Serial.println("-> ERROR");
}
if (strncmp(bufferReadGSM, "6",1) == 0){
Serial.println("-> NO DIALTONE");
}
if (strncmp(bufferReadGSM, "7",1) == 0){
Serial.println("-> BUSY");
}
if (strncmp(bufferReadGSM, "8",1) == 0){
Serial.println("-> CONNECT OK / NO ANSWER");
}
for(int a=0; a<=counter; a++){
bufferReadGSM[a]=0;
}
counter=0;
}
else{
counter++;
if (counter == bufferSize){
counter = 0;
if (debug > 1)
Serial.println("-> Buffer uerblauf");
Serial1.flush();
}
}
}
}
/*
PROGMEM string demo
How to store a table of strings in program memory (flash),
and retrieve them.
Information summarized from:
http://www.nongnu.org/avr-libc/user-manual/pgmspace.html
Setting up a table (array) of strings in program memory is slightly complicated, but
here is a good template to follow. Setting up the strings is a two-step process.
First define the strings.
*/
#include <avr/pgmspace.h>
char string_0[] PROGMEM = "String 0"; // "String 0" etc are the strings to store - change them to your text.
char string_1[] PROGMEM = "String 1";
char string_2[] PROGMEM = "String 2";
char string_3[] PROGMEM = "String 3";
char string_4[] PROGMEM = "String 4";
char string_5[] PROGMEM = "String 5";
// Then set up a table to refer to your strings.
PGM_P PROGMEM string_table[] = // change string_table to anything you wish
{
string_0,
string_1,
string_2,
string_3,
string_4,
string_5 };
char buffer[30]; // make sure this is large enough for the largest string it must hold
void setup()
{
Serial.begin(19200);
Serial.println( "Test" );
}
void loop()
{
/* Using the string table in program memory requires the use of special functions to retreive the data.
The strcpy_P function copies a string from program space to a string in RAM. Make sure your receiving string
in RAM is large enough to hold whatever you are retreiving from Program space.
There is some neccessary casts and dereferencing going on, just follow the template. */
for (int i = 0; i < 6; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i])));
Serial.println( buffer );
delay( 500 );
}
}
but when I look into the Serial Monitor it does always reset after the Setup routine has called.
So I just see my "Test" in the serial monitor....
I do use Arduino 0022 and an Arduino Mega 1280...
What's wrong with the code?