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

Pointer for a fprintf

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

Pointer for a fprintf
PostPosted: Thu Jul 06, 2017 6:18 am     Reply with quote

Hello everyone.

I did the following function, which sends AT commands to a GPRS module and waits for response or timeout.

There are some guts going on and I'm suspecting the pointers that are passed to this function.

Can anyone tell if something is wrong with this function?

Code:

#include <24FJ128GB204.h>
#build (stack=512)
#device PASS_STRINGS=IN_RAM


Code:

sendComandoAT("AT+SAPBR=2,1","+SAPBR:",3000);


Code:

unsigned int8 sendComandoAT ( char *pCmdAT, char *pAnswer, int16 timeWait)
{

int8 nCaracter=0;
char *ptr;

nCaracter = strlen(pAnswer);

fprintf(GPRS,"%s\r",pCmdAT);

while( (GPRS_DataPtr < nCaracter + 4 ) && (++ timeOutRx < timeWait) )
       {
       delay_ms(1);
       }

ptr=strstr(bufferRxMsgGPRS,pAnswer);

      if(strncmp(ptr,pAnswer,nCaracter)==0)
         {
         clearBuffer();
         timeOutRx=0;
         GPRS_DataPtr=0;
         return true;
         }
   
     else
         {
         clearBuffer();
         timeOutRx=0;
         GPRS_DataPtr=0;
         return false;
         }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Thu Jul 06, 2017 8:10 am     Reply with quote

AT+SAPBR=2,1, doesn't return +SAPBR: straight away. It returns OK first, then the +SABPR line a little later. Depending how your input function works, the strncmp, Won't return '0' if the leading 'OK\r' is there.
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Mon Jul 10, 2017 11:39 am     Reply with quote

That's right.

Thank you Ttelmah.
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