hi,
i working on sms-based system. system includes sim900 gsm/gprs module arduino supposed read sms.
when used at+cmgr command terminal program manually read sms module, able read complete sms. please see attached image named: "using terminal". however, when try read sms arduino using sketch attached , got incomplete message. please see attached image named: "using arduino".
i have tried fix issue no avail. kindly help! attach arduino sketch assistance.
thank you.
i working on sms-based system. system includes sim900 gsm/gprs module arduino supposed read sms.
when used at+cmgr command terminal program manually read sms module, able read complete sms. please see attached image named: "using terminal". however, when try read sms arduino using sketch attached , got incomplete message. please see attached image named: "using arduino".
i have tried fix issue no avail. kindly help! attach arduino sketch assistance.
thank you.
hi
waiting 3 seconds until processing response may cause serial buffer full , rest of message may lost.
i suggest wait 3 seconds process response character character data available.
is helpfull:
cheers
catweazle nz
waiting 3 seconds until processing response may cause serial buffer full , rest of message may lost.
i suggest wait 3 seconds process response character character data available.
is helpfull:
code: [select]
boolean readgsmrxdataresponse(const string &p_resp, const int &p_max_response_seconds) {
//many commands have standard 5 sec max response time, others twenty or sixty seconds
//sending sms has max 60 second response time (it allows poor network connectivity/retries)
//prior sending @ command cleared serial1 rx buffer.
//so not expect extraneous response related previous long running command.
//iterate response delay until have received first character of response
unsigned long l_timer = millis();
while (!checksecondsdelay(l_timer, p_max_response_seconds * 1000)) {
if (serial1.available()) {
break;
}
}
//once response character received assume have whole response
//readgsmrxdata includes 250ms delay between characters to
//allow response still coming.
readgsmrxdata();
string l_resp = p_resp;
l_resp.trim();
if (g_gsmrxdata == "") {
if (g_serialon)
serial.println(f("no data received"));
//
checkfreesram();
return false;
}
else if (l_resp == "") { //no particular response expected
checkfreesram();
return true; //the response can ignored
}
else if (g_gsmrxdata.indexof(l_resp) != -1) {
//we may want trim expected response (ok) off g_gsmrxdata
checkfreesram();
return true;
}
//we may have expected ok got error.
//or may have suffered comms error , recd garbage.
if (g_serialon) {
serial.print(f("response not found - "));
serial.println(g_gsmrxdata);
}
checkfreesram();
return false;
} //readgsmrxdataresponse
//----------------------------------------------------------------------------------------------
void readgsmrxdata() {
//available data known in rx buffer
//read , return via g_gsmrxdata
//application wide place serial1.read()
g_gsmrxdata = "";
unsigned long l_timer = millis();
while (!checksecondsdelay(l_timer, 250)) {
while (serial1.available()) {
char l_char; //always read char, append char g_gsmrxdata string
l_char = serial1.read();
g_gsmrxdata += l_char;
l_timer = millis(); //reset qtr sec timer
}
}
g_gsmrxdata.trim();
//no need force uppercase
checkfreesram();
} //readgsmrxdata
//----------------------------------------------------------------------------------------------
cheers
catweazle nz
Arduino Forum > Topics > Home Automation and Networked Objects > Arduino reading Incomplete SMS Text from SIM900
arduino
Comments
Post a Comment