Hi everybody
i'm working at a project of remote control using a PIC16F877 connected to my cell phone which i receive this response from my mobile phone :
+CMGR: "REC READ","+212673811922",,"09/11/22,17:24:38+00"
Bonjour ceci est un message de test
this message contains an AT command and the phone number and the timestamp
my question now is : How can i extract the data information (bonjour ceci est un ......) and make it in an Array or Table of character for compare it with another information coming from the keypad
i'm working with MiKroC ( langage C ).
comparaison of data coming from a mobile phone
-
- Posts: 4
- Joined: 21 Jun 2010 22:02
Re: comparaison of data coming from a mobile phone
Hi Everyone
i want to know if it's possible to manipulate the data coming from the mobile phone in the PIC16F877 (extract, comparison,....)
i'm working with MikroC (langage C)
thanks in advance
i want to know if it's possible to manipulate the data coming from the mobile phone in the PIC16F877 (extract, comparison,....)
i'm working with MikroC (langage C)
thanks in advance
Re: comparaison of data coming from a mobile phone
Hello,
Here's the example of how you could parse the string you are referring to. I've made the example that extracts everything that is contained between two quotation signs ("). Each extracted segment is then sent via RS232 for debugging:
The entire project is in the attachment, so you may test it and modify to suit your needs.
Best regards,
Aleksandar
Here's the example of how you could parse the string you are referring to. I've made the example that extracts everything that is contained between two quotation signs ("). Each extracted segment is then sent via RS232 for debugging:
Code: Select all
const PARAM_COUNT = 3;
unsigned char text[] = "+CMGR: \"REC READ\",\"+212673811922\",,\"09/11/22,17:24:38+00\"";
unsigned char temp[20];
unsigned char *start, *end;
unsigned short i;
void main() {
// Extract Segments
ADCON1 = 0x0F;
UART1_Init(9600);
i = 0;
start = text;
while (i <= PARAM_COUNT){
start = strchr(++start, '"');
if (start){
end = strchr(++start, '"');
if (end >= start){
strncpy(temp, start, end-start);
temp[end-start] = 0; // END WITH NULL
UART1_Write_Text(temp);
UART1_Write(13);UART1_Write(10); // CR+LF
start = end;
}
}
i++;
}
}
Best regards,
Aleksandar
- Attachments
-
- GSM_extract.rar
- (16.99 KiB) Downloaded 133 times
Web Department Manager
-
- Posts: 4
- Joined: 21 Jun 2010 22:02
Re: comparaison of data coming from a mobile phone
thank you very much Mr aleksandar.nikolic for your collaboration
i will modify it to suit my needs.
there is two question please : what's mean this instruction "ADCON1 = 0x0F;"
and what's the difference between those two instruction :
strchr(++start, '"');
strchr(start, '"');
the function returns a pointer to the '"' !!
thanks
i will modify it to suit my needs.
there is two question please : what's mean this instruction "ADCON1 = 0x0F;"
and what's the difference between those two instruction :
strchr(++start, '"');
strchr(start, '"');
the function returns a pointer to the '"' !!
thanks
Re: comparaison of data coming from a mobile phone
It is left here with no particular implications to the rest of the code. It is used to set all analog pins of PIC16F877 as digital I/O. Read more about this register in the chip's datasheet.what's mean this instruction "ADCON1 = 0x0F;"
This is just C-basics.and what's the difference between those two instruction :
strchr(++start, '"');
strchr(start, '"');
1. ++var means literally: "Increment the variable by 1 first, and then give me it's value"
2. The other just returns the variable value as it is. No prior increments.
Well, this was the whole point. Remember, I've already told you that this simple-parser extracts strings between two successive quotation characters. It returns the pointer to the next quotation mark, because it is supposed to do exactly that. The return value is used as a starting (or ending) point of the new string to be extracted from original buffer.the function returns a pointer to the '"' !!
Find more information on ANSI-C strings to make things clearer.
Best regards,
Aleksandar
Web Department Manager
-
- Posts: 4
- Joined: 21 Jun 2010 22:02
Re: comparaison of data coming from a mobile phone
ok thank you for your help i will give you feedback if anything doesn't work