Why function run twice?


#1

Hello all.
I from Ukraine. Sorry for my English. :blush:
I have a Fastrack Supreme 10, Firmware7.43, OS6.32.
My simply prog just send AT+CSQ command and save response in Buffer_ST.Can anybody answer me. why my function my_Read_Csq( ) run twice? And that’s why Buffer_SS=Nothing, and Buffer_ST=[SG=].
I see that in Traces View:
10/08/02,06:12:02:640 ADL 1 In main_task
10/08/02,06:12:08:15 ADL 1 In Signal_stn
10/08/02,06:12:08:15 ADL 1 wm_strGetParameterString ( Buffer_SS ,ptr ,1)
10/08/02,06:12:08:31 ADL 1 27
10/08/02,06:12:08:31 ADL 1 [SG=27]
10/08/02,06:12:08:359 ADL 1 wm_strGetParameterString ( Buffer_SS ,ptr ,1)
10/08/02,06:12:08:375 ADL 1 [SG=]

#include "adl_global.h"
#include "generated.h"

bool my_Read_Csq( adl_atResponse_t *paras )
{
	ascii * ptr;
	ascii  Buffer_ST[20];
	ascii  Buffer_SS[20];
	ptr = paras->StrData;
	wm_strGetParameterString ( Buffer_SS ,ptr ,1);
TRACE (( 1, "wm_strGetParameterString ( Buffer_SS ,ptr ,1)" ));
	wm_strcpy(Buffer_ST,"[SG=");
	wm_strcat(Buffer_ST,Buffer_SS);
	wm_strcat(Buffer_ST,"]");
TRACE (( 1, Buffer_SS ));
TRACE (( 1, Buffer_ST ));
	adl_atSendResponse(ADL_AT_RSP,Buffer_ST);
	return FALSE;
}

void Signal_stn( adl_atCmdPreParser_t *p)//u8 ID, void * Context
{
	adl_atCmdCreate("at+csq", ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE),(adl_atRspHandler_t)my_Read_Csq, "*", NULL);
TRACE (( 1, "In Signal_stn" ));
}

void main_task (adl_InitType_e InitType)
{
TRACE (( 1, "In main_task" ));
	adl_atCmdSubscribe ("at+a", (adl_atCmdHandler_t)Signal_stn, ADL_CMD_TYPE_ACT);
}

Thanks for answers.


#2

Because the AT+CSQ command gives two responses!

  1. +CSQ: x,y - An Intermediate response;
  2. OK - the [i]Terminal /i response.