i am using gsm modem ! I USE CMGL COMMAND TO DISPLAY THE
LIST OF MESSAGES ! I WANT TO READ EACH MESSAGE ONE BY ONE
AND GET EACH MESSAGE INDEX USING C PROGRAM ! THE RESPONSE OF
THE MODULE AFTER AT+CMGL IS
---CMGL: 1,"REC
READ","+85291234567",,"07/05/01,08:00:15+32",145,37
It is easy to list SMS text messages.----
I WANT THE PROGRAM TO GET THE NUMBER "37"{MESSAGE LENGTH}
AS WELL AS "1"(MESSAGE INDEX NUMBER"
PLEASE HELP
Answer Posted / senthil
assume the read message string is stored in a buffer buf already
char buf[100] = "CMGL: 1,\"REC READ\",\"+85291234567\",,\"07/05/01,08:00:15+32\",145,37";
int comma_cnt = 0, i, j;
char msgidx[10];
char msglen[10];
if(strncmp("CMGL:", buf, 5) == 0)
{
// copy message index till comma
for(i=5, j=0; buf[i] != ','; i++)
{
msgidx[j++] = buf[i];
}
msgidx[j] = 0;
i++; // loc after comma;
comma_cnt = 1;
for(; buf[i] != 0; i++)
{
// check for commas
if(buf[i] == ',')
{
// check for 7th comma
if(++comma_cnt == 7)
{
comma_cnt = 0;
strcpy(msglen, buf+i+1);
printf("message index = %s\n", msgidx);
printf("message length = %s\n", msglen);
}
}
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is the difference between 123 and 0123 in c?
How do you write a program which produces its own source code as output?
What is the difference between text and binary i/o?
What is the benefit of using an enum rather than a #define constant?
Why do we need functions in c?
What is LINKED LIST? How can you access the last element in a linked list?
Differentiate between ordinary variable and pointer in c.
in linking some of os executables are linking name some of them
Do you know pointer in c?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
How can I access an I o board directly?
How can I delete a file?
What is the function of multilevel pointer in c?
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
Explain what is the advantage of a random access file?