|
|
View previous topic :: View next topic |
Author |
Message |
dsp
Joined: 14 Jan 2005 Posts: 2
|
receive AT command |
Posted: Fri Jan 14, 2005 1:10 pm |
|
|
Hi,
I'm sending to my phone AT commands and it works OK, but I'm trying to read the gsm response "NO CARRIER" with gets(), this is a part, (thank all in advance):
#include <16f870.h>
#fuses NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,XT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=n)
char string[11];
call()
{
printf("ATD my number \r");
}
read()
{
gets(string); //I can't continue here
printf("\r");
printf("%s\r",string); //to check with port monitor
}
main()
{
do
{
output_high(PIN_C5);
delay_ms(5000);
call();
read();
output_low(PIN_C5);
delay_ms(150000);
}
while(TRUE);
} |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jan 14, 2005 1:22 pm |
|
|
gets() is a good way to lock up your system. What does it do?
Quote: |
Reads characters (using GETC()) into the string until a RETURN (value 13) is encountered. |
Now what happens if we don't get the 13 or there is an error. Well, it is going to sit there and wait forever. Now if you were entering data in by a terminal or something, this might be okay since you would probably hit enter if something doesn't go right. The phone isn't going to do that. I would use an interrupt to receive the data into a buffer. In your application you could read from this buffer looking for the 13. If you don't get it within a specified timeout, you could take the appropriate action. |
|
|
dsp
Joined: 14 Jan 2005 Posts: 2
|
|
Posted: Fri Jan 14, 2005 1:36 pm |
|
|
ok, I will work with this option, thank you Mark |
|
|
tsupuntu Guest
|
Please post schematic for recieve ATcommand |
Posted: Thu Aug 18, 2005 3:22 pm |
|
|
Please post schematic for recieve ATcommand
Thank in advance |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|