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

problem with at commands

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







problem with at commands
PostPosted: Wed Jan 07, 2009 2:14 am     Reply with quote

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
PostPosted: Wed Jan 07, 2009 2:36 am     Reply with quote

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

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

PostPosted: Wed Jan 07, 2009 4:30 am     Reply with quote

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
PostPosted: Wed Jan 07, 2009 4:49 am     Reply with quote

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
PostPosted: Wed Jan 07, 2009 9:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 9:54 am     Reply with quote

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
PostPosted: Wed Jan 07, 2009 9:52 pm     Reply with quote

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
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