firefoxvn
Newbie level 1
Hi, I want to filter string that reply from SIMCOM. I have the string: xxxxxxxx +12345678 xxxxxx. The string "+12345678" is that I want. I do following steps:
- Check rx_counter!=0
- Create array has 10 char, array[0] starts from "+"
- If (array = UDR)==CR, program break;
- Check if rx_counter==0, copy string to another array has 10 char
- Send it to LCD or TX line.
Here is my code:
But its did not work, I don't understand my code was wrong or the way I think was wrong. Help me fix the code, please. Thanks for reading and sorry for my English. I'm foreigner.
- Check rx_counter!=0
- Create array has 10 char, array[0] starts from "+"
- If (array = UDR)==CR, program break;
- Check if rx_counter==0, copy string to another array has 10 char
- Send it to LCD or TX line.
Here is my code:
Code:
#define MAXCHAR 40
#define CR 13
char int_buff[MAXCHAR];
void check_SMS()//Check SMS sends case
{
unsigned int i;//Create int var
char content[10];//create array has 10 character
i=0;//set i=0
int_buff[0]='+';//create array int_buff[0] starts from "+"
while((i<MAXCHAR) && (rx_counter>0))//
{
if((int_buff[i++]=UDR)==CR) break;//The program stops when UDR=int_buff=CR, CR is enter key and equal 13 in ASCII.
delay_ms(500);
}
if(rx_counter==0)//if rx_counter=0, transmit is finished
{
strcpy(content,&int_buff[i]);//Copy data from int_buff to content
puts(content);
lcd_gotoxy(0,0);
lcd_puts(content);//Print it to LCD
delay_ms(500);
}