|
|
View previous topic :: View next topic |
Author |
Message |
Orcino
Joined: 07 Sep 2003 Posts: 56
|
Pointer for a fprintf |
Posted: Thu Jul 06, 2017 6:18 am |
|
|
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: 19499
|
|
Posted: Thu Jul 06, 2017 8:10 am |
|
|
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
|
|
Posted: Mon Jul 10, 2017 11:39 am |
|
|
That's right.
Thank you Ttelmah. |
|
|
|
|
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
|