Q24pl fcm => rs232


#1

I’m trying to use the FCM in order to drive a device with my Q24PL.

For my 1rst try i made this program :

#include "adl_global.h"
#include "adl_fcm.h"

u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );

/***************************************************************************/
/*  Local variables                                                        */
/***************************************************************************/
s8 fcm_FcmHandle;
u16 timer;
u16 times;

/***************************************************************************/
/*  Local functions                                                        */
/***************************************************************************/
void repeatexit()
{
	adl_atSendResponse(ADL_AT_RSP,"FIN\r\n");
}

void StartScan()
{
	adl_atSendResponse(ADL_AT_RSP, "S Scan\r\n");
	adl_fcmSendData ( fcm_FcmHandle, "S", 1);
	adl_atSendResponse(ADL_AT_RSP, "E Scan\r\n");

	if (times>1)
	{
		times--;
		adl_tmrSubscribe ( FALSE, timer, ADL_TMR_TYPE_100MS, StartScan);
	}
	else
	{
		adl_fcmUnsubscribe(fcm_FcmHandle);
		adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, repeatexit);		
	}
}

bool fcm_Line_CtrlHdlr ( u8 event)
{
	switch (event)
	{
	case ADL_FCM_EVENT_FLOW_OPENNED:
		adl_fcmSwitchV24State(fcm_FcmHandle,ADL_FCM_V24_STATE_DATA);
		break;

	case ADL_FCM_EVENT_V24_DATA_MODE:
		timer = 10;
		times = 10;
		StartScan();		
		break;

	case ADL_FCM_EVENT_FLOW_CLOSED:
		// nothing 
		break;

	default:
		// nothing
		break;
	}
	return(FALSE);
}

bool fcm_Line_DataHdlr ( u16 DataLen, u8 * Data )
{
	ascii buf[260];
	u16   DataTrans;
	u16   DataBuf;

	DataBuf = 0;
	for ( DataTrans = 0; DataTrans < DataLen && DataBuf < 255; DataTrans++, DataBuf++)
    {
		buf[DataBuf] = Data[DataTrans];
    }
	buf[DataBuf]='\0';
	return(TRUE);
}

bool Cmd_FCM_Handler(adl_atCmdPreParser_t * params)
{
	u8 val;
	ascii buf[100];
	bool b_return = TRUE;

	switch(params->Type)
	{
	case ADL_CMD_TYPE_ACT:
		wm_sprintf(buf, "FCM enabled\r\n");		
		adl_atSendResponse(ADL_AT_RSP, buf);
		break;

	default :
		b_return = FALSE;
		break;
	}

	if ( b_return == TRUE )
	{
		adl_atSendResponse(ADL_AT_RSP, "\r\nOK\r\n");
		fcm_FcmHandle =  adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1, fcm_Line_CtrlHdlr, fcm_Line_DataHdlr);
	}
	else
	{
		adl_atSendResponse(ADL_AT_RSP, "\r\nERROR\r\n");
	}

	return FALSE;
}

/***************************************************************************/
/*  Function   : adl_main                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application initialisation                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  InitType          |   |   |   |  Application start mode reason         */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{      
	adl_atCmdSubscribe("AT+FCM",( adl_atCmdHandler_t )Cmd_FCM_Handler, ADL_CMD_TYPE_ACT);    
}

When i type AT+FCM
This program should open FCM flow at send every 1 second the char ‘S’
When i type my command the flow is opened and nothing appends.
Someone can help me about this ?