CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

receive AT command

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dsp



Joined: 14 Jan 2005
Posts: 2

View user's profile Send private message

receive AT command
PostPosted: Fri Jan 14, 2005 1:10 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 14, 2005 1:22 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 14, 2005 1:36 pm     Reply with quote

ok, I will work with this option, thank you Mark
tsupuntu
Guest







Please post schematic for recieve ATcommand
PostPosted: Thu Aug 18, 2005 3:22 pm     Reply with quote

Please post schematic for recieve ATcommand

Thank in advance
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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