View previous topic :: View next topic |
Author |
Message |
Lykos1986
Joined: 26 Nov 2005 Posts: 68
|
|
Posted: Fri Feb 15, 2008 11:11 am |
|
|
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
|
|
Posted: Mon Feb 18, 2008 1:03 pm |
|
|
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
|
|
Posted: Tue Feb 19, 2008 2:14 am |
|
|
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
|
|
Posted: Tue Feb 19, 2008 6:45 am |
|
|
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
|
|
Posted: Sat Apr 12, 2008 3:02 pm |
|
|
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
|
|
Posted: Tue Dec 15, 2009 6:25 am |
|
|
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. |
|
|
|