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

times between commands

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



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

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

times between commands
PostPosted: Tue Jul 13, 2004 6:18 am     Reply with quote

Hello

My program stop when I read a incoming message from a GSM Modem and I thing the problem is the times between commands.

Somebody can help me? Therefore already I tried all posts related with SMS reading.

some code:

Code:

//...
OFF_int();  //desable INT_ext and INT_rda
delay_ms(100);
fprintf(COM_B, "AT+CMGR=1\n");   //command to read message
delay_us( 1000 );
     do {                       //wait for CR
      c=fgetc(COM_B);
      } while (c!=13);
            
      letra =0;
   
      do {                        //save text message
      buffer1[letra]=fgetc(COM_B);
      letra++;
      } while (letra == 16);

      read_int_eeprom_string(s, ROM_mensagem, ROM_mensagem_SIZE); // read from eeprom text to compare
      if (strncmp (buffer1, s, 8)==0)      //compare both message
         {
         fprintf(COM_A,"Turn ON\r\n");
         output_high (pin_b5);
               
         }
//... continue



Thank you

Carlos
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jul 13, 2004 7:37 am     Reply with quote

Are you using a software UART? If so the CPU is entirely occupied while reading serial data.
Rather than reading in a whole buffer full of data and then comparing, I would compare each character as it comes in. That way you don't use two buffers of RAM space. Even with characters coming in with no inter character space you usually have at least half the stop bit time to process the old character before you need to start reading the new character.
Also this line looks wrong
} while (letra == 16);
should it be <= instead of == ?
_________________
The search for better is endless. Instead simply find very good and get the job done.
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

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

PostPosted: Tue Jul 13, 2004 7:59 am     Reply with quote

No
I use hardware port like
Code:

#use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7, PARITY=n, bITS=8, STREAM=COM_B, ERRORS)  //hardware
#USE RS232(BAUD=9600, XMIT=PIN_B1, RCV=PIN_B0, STREAM=COM_A, ERRORS)


Already I tried to compare while it read, but had problems with CR and LF.
Thank you

Carlos
Guest








PostPosted: Tue Jul 13, 2004 8:53 am     Reply with quote

Your uart is overflowed.
First of all, you have to init your GSM adapter by a
ATE0+CMGF=1
command to disable local echo and to set text mode. Without local echo disabled, your commands is echoed to the PIC. Your INT_RDA is disabled, so the receiver circuit is fullfilled after the 'T' char of your AT+CMGR command. Once the receiver is overflowed, it stops the work. The ERRORS will clear this state _after_ the first incoming char what is the 0x0D. So you will never get the first 0x0D (a typical answer from the adapter looks like this:
0x0D 0x0A +CMGR: 1 0x0D 0x0A YourText............... 0x0D 0x0A

So use either IT-driven receive or wait for 10 dec. (0x0A) in your loop (that is the 2nd char at the beginning).
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