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 CCS Technical Support

Serial communication for AT commands...
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Fri Feb 15, 2008 11:11 am     Reply with quote

Ok… maybe I will make a PCB surgery! I will reverse the TX and RX pins. After that I will be able to use the hardware UART of PIC. I think it is better like that. May I have an example code for the settings of the UART (how to put the 8N1) and how to give the AT command and take the OK response through the hardware UART?

Thank you…
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Mon Feb 18, 2008 1:03 pm     Reply with quote

After the circuit surgery I am able to use the Hardware UART of the PIC. But the problem still remains. The only response I have is the echo! I give AT and I take AT!!! I really don’t know what I have to do!
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 2:14 am     Reply with quote

You are checking for "OK"

Quote:

strcpy(string2,"OK");
...
fprintf(PC, "AT\r\n");
gets(string1);
if(!strcmp(string1, string2))
{
output_high(L1);
}
}


string1 is most ikely longer than string2 and so the comparison will fail.

The response to AT is more likely to be "OK\r\n>" or something similar!
try using strncmp(string1, string2, 2) to just compare 2 chars.
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Feb 19, 2008 6:45 am     Reply with quote

It's worse than that - as the 'AT\r\n' bytes are being sent the Telit will echo straight away for each character, so the gets (most likely) wont catch the echo'ed reply. Although it might see the last newline char, assume that the string is collected, and so return an empty string. The original poster really should look at interrupt buffered character reception, there are many examples on this forum of code.
dilandau
Guest







PostPosted: Sat Apr 12, 2008 3:02 pm     Reply with quote

Ok, despite I see this post is a bit old I would like to add my advise to the problem.

Look at the code

Code:

while(1)
{
   if(input(F1))
   module_on();


   if (input(F2))
   {
      fprintf(PC, "AT\r\n");
      gets(string1);
      if(!strcmp(string1, string2))
      {
         output_high(L1);
      }
   }

}


You send an AT command and you received the echo. The function Gets will read until the first "\r", so you get your echo in "string1".
Imagine that your module takes 200 ms to respond with the "OK\r\n", you dont have in your code anything to get it. Fast option is to call again to the gets function, better option should be buffering every rda interruption, wait some time and check buffer with strstr() function.

Hope this helps..
nuqem



Joined: 15 Dec 2009
Posts: 4

View user's profile Send private message

PostPosted: Tue Dec 15, 2009 6:25 am     Reply with quote

Hi.
Did you try to switch off the echo with ate0?

I also want to make a communication with a Telit gm862 modem. Is there somebody who finished it already?
For the beginning I just want to send az at and to confirm that the modem gives back an OK.
As I make a communication with hyperterminal I saw that the answer gives in format <cr><lf>OK<cr><lf>
How could I make a comparison of the input string to watch just the texts ? And to see what is modem giving back.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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