View previous topic :: View next topic |
Author |
Message |
faraz100 Guest
|
problem with at commands |
Posted: Wed Jan 07, 2009 2:14 am |
|
|
guys here is my code it works fine for only one time second time when i push the switch it hangs out a do nothing
Code: | #include "C:\Temp\FST AT\FSTAT.h"
#include <string.h>
void main()
{
char mobile[22];
char refr[22]="OK";
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
if(input(pin_a0))
{
delay_ms(500);
puts("AT");
gets(mobile);
if(stricmp(mobile,refr))
{
puts("ATD 00923215702782");
gets(mobile);
}
}
}
} |
waiting for ur reply and comments |
|
|
faraz100 Guest
|
problem with at commands |
Posted: Wed Jan 07, 2009 2:36 am |
|
|
guys i have test the program in proteus. i have used two pic one as a mobile which recieve "AT" and reply "OK". First time every thing is ok but second time mobile's reply is "OK" but debugging in proteus this string shows "O" one the second location and "k" is in third location of the string while first location of the string shows "0X0A". Now what i have to do.
thanx |
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Wed Jan 07, 2009 4:30 am |
|
|
For more reactions you might want to explain your problem a bit further. I can understand what is going on, but I do not entirely know what you want to happen.
I suspect you want to get rid of the 0x0D character (Newline I believe). You can accomplish this by flushing your serial port after your loop. Something like this might do the trick:
Code: | while(1)
{
if(input(pin_a0))
{
delay_ms(500);
puts("AT");
gets(mobile);
if(stricmp(mobile,refr))
{
puts("ATD 00923215702782");
gets(mobile);
}
}
while (getc()); //Flush any remaining characters
} |
Hope this helps,
Jos |
|
|
faraz100 Guest
|
problem with at commands |
Posted: Wed Jan 07, 2009 4:49 am |
|
|
sorry i have posted wrong code my updated code is here i just want to make a call with at commands. But my code works only for the first time when i power up the hardware and second time do nothing. I am using sony ericsson t230
Code: |
#include "C:\Temp\FST AT\FSTAT.h"
#include <string.h>
void main()
{
char mobile[22];
char refr[22]="ok";
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
if(input(pin_a0))
{
delay_ms(500);
puts("AT");
gets(mobile);
if(strcmp(mobile,refr)==0)
{
puts("ATD 00923215702782");
}
else
{
puts("ERR");
}
}
}
}
|
|
|
|
faraz100 Guest
|
problem with at commands |
Posted: Wed Jan 07, 2009 9:43 am |
|
|
where are the xperts.i m waiting for your response please have a look at my problem
thanx |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 07, 2009 9:54 am |
|
|
Quote: | char refr[22]="ok";
if(strcmp(mobile,refr)==0)
|
Your 'refr' string is in lower case. The modem sends an "OK" response in
upper case. |
|
|
faraz100 Guest
|
problem with at commands |
Posted: Wed Jan 07, 2009 9:52 pm |
|
|
Again no success. In proteus debugging at first time when I press the button both string have "O" and "K" in their first and second location or byte.
But at the second press of switch the string from mobile shows "0x0A" at the first location "O" at the second location and "K" at the third location. So the strcmp fails.
How can I solve it ?
Thanx |
|
|
|