Microcontroller › PIC › reading sms from gsm modem and comparing with predefind one
- This topic has 23 replies, 7 voices, and was last updated 8 years, 2 months ago by narasimha rao.
-
AuthorPosts
-
July 24, 2012 at 4:34 am #1889tdParticipant
hi,
in our project, we are using pic 18f and modem sim 300.and we are using c18 compiler.in that i have written program for sending and receiving sms through gsm modem.when i use the AT command for reading sms, i m getting like this
AT+CMGR=1
+CMGR: “REC READ”,”+918108111649″,,”12/07/22,14:24:11+22″
HelloOK
here i have to read the sms “Hello”, which comes before “OK”.and compare it with a predefined string. i write for parsing string.but i m not getting the word “Hello”. here is codes…
<code>
putrsUSART(“ATnr”);
putrsUSART(“AT+CMGF=1”);
putcUSART(0x0D);
Delay10KTCYx(500);
putrsUSART(“AT+CMGR=1”);
putcUSART(0x0D);
Delay10KTCYx(500);if(PIR1bits.RCIF)
{
for(i=0;i<5;i++)a=getcUSART();
}
putsUSART(a);
</code>
while exicuting this, i m getting “a ” as some srange characters like ?2k> or ?ï2oÈ
how can i extract the messange hello?? please help me to solve this problem.
thank you
July 24, 2012 at 9:20 am #8320ManikandanParticipantHi,
I think delay may be the problem. please check and correct the delay.
Thank you,
Manikandan A
July 25, 2012 at 4:20 am #8325tdParticipantThank you for reply.
i have reduced the delay .and took the buffer like a[50],
in both case stange characters are coming.
July 25, 2012 at 11:10 am #8327tdParticipantthanks for reply..
what you mean by
if(Rcv_Byte==arr1[count]||count>5)
is that necessary to set flag??
July 25, 2012 at 2:02 pm #8329tdParticipantthank you
here your program is for getting hello only..but the modem response is
+CMGR: “REC READ”,”+918108111649″,,”12/07/22,14:24:11+22″
Hello
OKso 1st we have to read these whole string.how can i read this whole sting?
i used some inbuilt functions for reading charecter wise.but some strange characters are coming.here is my code.
for(i=0;i<70;i++)
a=getcUSART();
}
putsUSART(a);how can i input that whole sting to pic?
July 29, 2012 at 10:40 am #8360tdParticipanti changed the steps, but i m not getting the string…
+CMGR: “REC READ”,”+918108111649″,,”12/07/22,14:24:11+22″
HelloOK
here is the pgm……
putrsUSART(“AT+CMGR=1”);
putcUSART(0x0D);while(BusyUSART());
gets(a);
Delay1KTCYx(75);
putsUSART(a);}
void gets(char *buffer)
{
unsigned char data;
do
{
while(!DataRdyUSART());// Wait for data to be received
data = getcUSART();
*buffer = data;
buffer++; // Increment the string pointer
}
while(data!=’K’);
*buffer=’