FCM problem

Hi,
I’m using q2406B module with 6.52 firmware.
I tried to write some code using FCM to sent data out from module.
When I run in remote mode, using terminal emulator I can see data sent in data window, not in At window.
But when I try to run in target mode, I can’t see anything using hyperterminal. No data sent out via UART from module.
Please help any solution for this problem ?

I assume you’re talking about the old Wavecom “Terminal Emulator” (TE) here - as used in conjunction with the corresponding old Target Monitoring Tool (TMT)?

That is correct.

What about using Terminal Emulator (TE)?

I’m using Target monitoring tool v 2.7.4, which comes with openat sdk v 3.04.
In terminal emulator there is AT window and data window.
When using terminal emulator, here is the result,
in remote mode

  • modem could response to command sent in At window
  • some data sent out from modem to pc on data window
    in target mode
  • modem could response to command sent in At window
  • nothing sent out from modem to pc on data window.

What i want is

  • modem could respone to command sent in At window, and some data sent out from modem to pc on At window

Use the TRACEs in TMT to debug your problem…

I’ve tried using TRACE, but i didn’t now what’s wrong. Here is snippet

//#include "wm_stdio.h"
#include "adl_global.h"
#include "adl_at.h"
#include "adl_fcm.h"
#include "adl_sim.h"
#include "adl_flash.h"
#include "adl_memory.h"
#include "wm_at.h"
#include "wm_fcm.h"

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

adl_tmr_t * tmr_qry;
static u8 socket_TraceLevel=2;
static int i=1;
ascii * PinCode=NULL;
s8  sReturn = ERROR;

void SimHandler ( u8 Event );
void Timer_QryHandler(u8 Id);


    #define UART_1 ADL_AT_PORT_TYPE(ADL_PORT_UART1,ADL_AT_RSP) /* refer to ADL User Guide pag 67, rspflag */

    /* --- UART Config enums --- */
    /* Data format */
    enum UART_FORMAT{

       NO_USE,
       DATA8_STOP2,
       DATA8_STOP1_PARITY1,
       DATA8_STOP1,
       DATA7_STOP2,
       DATA7_STOP1_PARITY1,
       DATA7_STOP1

    };

    /* parity bit config */
    enum UART_PARITY{

       ODD,
       EVEN,
       MARK,
       SPACE,
       NONE_PARITY

    };

    /* flow control */
    enum UART_FLOW_CONTROL{

       CTS_RTS,
       NO_CTS_RTS

    };

    /* UART mode type */
    enum UART_TYPE{

       DATAMODE,
       ATMODE

    };
    static bool EvhCrtlUart1(adl_fcmEvent_e evnt);
    static bool EvhDataUart1(u16 datalength, u8 *data);
    static void EvhConfUartx(adl_atResponse_t *Rsp);

    s8 handle_uart1;                     /* UART1 handler */
    u8 mode_uart1;                        /* UART1 mode type */
	u8 buff[150];
	u8 pos=0;

    int initUART1(u8 mode, int speed, u8 format, u8 parity, u8 flow_control){

       char comand[15];
       /* Check if port available*/
       {
          /* Save UART operation mode: DATA o AT*/
          mode_uart1=mode;
			TRACE (( 1, "Init Uart"));

          /* subscribe to FCM uart service */
          handle_uart1=adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1, EvhCrtlUart1,EvhDataUart1);
			TRACE (( 1, "%d",handle_uart1));
          switch(handle_uart1){
          case ADL_FCM_EVENT_FLOW_OPENNED:
				TRACE (( 1, "FCM init flow opened"));
             break;
          case ADL_RET_ERR_PARAM:
				TRACE (( 1, "FCM init send data: parameter incorrect value"));
             break;
          case ADL_RET_ERR_ALREADY_SUBSCRIBED:
				TRACE (( 1, "FCM init already subscribed"));
             break;
          case ADL_RET_ERR_NOT_SUBSCRIBED:
				TRACE (( 1, "FCM init not subscribed"));
             break;
          case ADL_FCM_RET_ERROR_GSM_GPRS_ALREADY_OPENNED:
				TRACE (( 1, "FCM init gsm gprs already opened"));
             break;
          case ADL_RET_ERR_UNKNOWN_HDL:
				TRACE (( 1, "FCM init send data: unknown handle"));
             break;
          case ADL_RET_ERR_BAD_STATE:
				TRACE (( 1, "FCM init send data: not ready to send data"));
             break;
          case ADL_FCM_RET_ERR_WAIT_RESUME:
				TRACE (( 1, "FCM init send data: flow has no more credit"));
             break;
          }

          /* config parity with AT Command*/

          wm_sprintf(comand,"AT+ICF=%d,%d", format, parity);
          adl_atCmdCreate(comand, FALSE,EvhConfUartx,NULL);

          /* speed  with AT Command*/
          wm_sprintf(comand,"AT+IPR=%d", speed);
          adl_atCmdCreate(comand, FALSE,EvhConfUartx,NULL);

          /* flow control  with AT Command*/
          switch(flow_control){
          /* hardware flow control */
          case CTS_RTS:
             adl_atCmdCreate("AT+IFC=2,2",FALSE,EvhConfUartx,NULL);
             break;
             /* no hardware flow control */
          case NO_CTS_RTS:
             adl_atCmdCreate("AT+IFC=0,0",FALSE,EvhConfUartx,NULL);
             break;
          }
          /* save configuration */
		  tmr_qry=(adl_tmr_t *)adl_tmrSubscribe(FALSE, 50, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) Timer_QryHandler);			
          return 0;
       }

    }/*initUART1*/

    static bool EvhCrtlUart1(adl_fcmEvent_e evnt){
		s8 error;
		ascii data[20];

			TRACE (( 1, "Event Ctrl uart"));
       switch (evnt)
        {
        /* when com is open, operation mode is defined */
        case ADL_FCM_EVENT_FLOW_OPENNED:
           /*  DATA MODE */
           if(mode_uart1 == DATAMODE){
				TRACE (( 1, "FCM open data mode"));
              error = adl_fcmSwitchV24State(handle_uart1,ADL_FCM_V24_STATE_DATA);
				TRACE (( 1, "Switch state = %d", error ));
				switch(error){
				case OK :
					TRACE (( 1, "Switch to Data : OK"));
					break;
				case ADL_RET_ERR_PARAM :
					TRACE (( 1, "ADL_RET_ERR_PARAM"));
					break;
				case ADL_RET_ERR_UNKNOWN_HDL :
					TRACE (( 1, "ADL_RET_ERR_UNKNOWN_HDL"));
					break;
				case ADL_RET_ERR_BAD_HDL :
					TRACE (( 1, "ADL_RET_ERR_BAD_HDL"));
					break;
				}
           }
           /* AT MODE */
           else if(mode_uart1 == ATMODE){
				TRACE (( 1, "FCM open data atmode"));
              //adl_atSendResponse(ADL_AT_RSP, "\r\nUART1: AT Mode");
              adl_fcmSwitchV24State(handle_uart1,ADL_FCM_V24_STATE_AT);
           }
           break;

        case ADL_FCM_EVENT_FLOW_CLOSED:
				TRACE (( 1, "FCM Closed OK"));
			break;
        case ADL_FCM_EVENT_V24_DATA_MODE:
           /* DATA MODE OK */
				TRACE (( 1, "Data mode OK"));
           break;
        case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
           /* DATA MODE OK */
				TRACE (( 1, "Data mode ext OK"));
           break;

        case ADL_FCM_EVENT_V24_AT_MODE:
           /* AT MODE OK */
				TRACE (( 1, "At mode OK"));
           break;
        case ADL_FCM_EVENT_V24_AT_MODE_EXT:
           /* AT MODE OK */
				TRACE (( 1, "At mode ext OK"));
           break;

        case ADL_FCM_EVENT_RESUME:
				TRACE (( 1, "Resume OK"));
           break;

        case ADL_FCM_EVENT_MEM_RELEASE:
				TRACE (( 1, "Mem release OK"));
           break;

        default:
				TRACE (( 1, "Default event"));
           return FALSE;
           break;
        }
        return TRUE;
    }/*EvhCrtlUart1*/

    static bool EvhDataUart1(u16 datalength, u8 *data){
       /* when data recived echo it */
       s8 error;
	   u8 i;
	   ascii buffdata[50];

		wm_strncpy(buffdata, data, datalength);
       /* check for ESC to switch to AT MODE */
		TRACE (( 1, "Data Uart Handler"));
		TRACE (( 1, "Pos = %d", pos));
		
		for(i=0;i<datalength;i++){
			buff[pos] = data[i];
			//*data++;
			pos++;
		}	

		if(pos==101){
			// parse
		}
		
       return TRUE;

    }/*EvhDataUart1*/

    static void EvhConfUartx(adl_atResponse_t *Rsp){

    }/*EvhConfUartx*/

void Timer_QryHandler(u8 Id)
{
	s8 error;
	u8 Buff[50];
	u16 i;
	Buff[0] = 111;
	Buff[1] = 3;
	Buff[2] = 0;
	Buff[3] = 0;
	Buff[4] = 0;
	Buff[5] = 3;
	Buff[6] = 77;
	Buff[7] = 80;
	// qry pmac
	TRACE (( socket_TraceLevel, "Timer_Qry" ));
	for(i=0;i<pos+1;i++){buff[i]=0;}
	pos=0;
	error = adl_fcmSendData(handle_uart1,&Buff,8);
	TRACE((1,"Qry1 %d\r",error));
	
	tmr_qry=(adl_tmr_t *)adl_tmrSubscribe(FALSE, 50, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) Timer_QryHandler);			
}

//Pin Code CallBack
void SimHandler ( u8 Event )
{
	ascii Buff[50];

	wm_sprintf ( Buff, "SimHandler: %d\r\n",Event );
	TRACE (( socket_TraceLevel, Buff ));
	
	 switch ( Event )
    {
        case ADL_SIM_STATE_FULL_INIT :
			//Pin Code OK
			TRACE (( socket_TraceLevel, "ADL_SIM_STATE_FULL_INIT" ));
			
			initUART1(DATAMODE, 115200 , DATA8_STOP1 , NONE_PARITY , NO_CTS_RTS);
			break;
	}
	
}

/***************************************************************************/
/*  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 )
{
	TRACE (( 1, "Embedded Application : Main" ));

	adl_simSubscribe(SimHandler,PinCode);
	TRACE (( 1, "Ed_Init : %d", sReturn));

}

The fcm_SendData in Timer_QryHandler used to send data out from modem to PC

error = adl_fcmSendData(handle_uart1,&Buff,8);
	TRACE((1,"Qry1 %d\r",error));

In remote mode, using terminal emulator I got data sent in data window, not in AT window.
In target mode, using terminal emulator, I got nothing on both At and data window.
How to fix this, so it could be sent to at window?

Hi,
I’ve got similar problem.
I want to write and read data from uart1.
I have subscribe to fcm, get UART1 handler and return OK.
For debugging I’m using TMT and TE. Each time I write data using fcmSendData to UART1 handler, I can see data written in TE data window. I assume TE data window display any data on ‘virtual port’, because it was not shown when using win hyperterminal.
I read on user manual, there is a need to activate port using AT+WMFM. Only I can’t found any working sample code.
Please, any suggestion tp fix the problem.

Hi all.
I’m facing the same problem… I can subscribe to fcm but the modem does not send any data using adl_fcmSendData… I know it receives something because It does respond to AT commands, but the handler of data received never gets executed. Should be great if some body came up with a solution. Thanks in advance and I post my code for reference… pd: please excuse my english.

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

/*VARIABLES GLOBALES*/
u8 Handle;
bool fcmCtrlH(adl_fcmEvent_e event);
bool fcmDataH(u16 DataLen, u8 * Data);


void main_task(void) {
	// TODO Insert your task initialization code here
	Handle=adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1, fcmCtrlH, fcmDataH);
	TRACE((1,"Aplicación principal"));
}

bool fcmCtrlH ( adl_fcmEvent_e event )
{
TRACE ((1, "Control event received --> %d", event));
switch(event)
{
case ADL_FCM_EVENT_FLOW_OPENNED:
TRACE (( 1, "Flow Opened" ));
/* Switching V24 state from AT to Data. */
adl_fcmSwitchV24State(Handle, ADL_FCM_V24_STATE_DATA);
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
TRACE (( 1, "Flow in Data Mode" ));
/* sending data to the external application via V24 serial link */
adl_fcmSendData(Handle, "This is a test case", 19);
break;
}
return TRUE;
}

bool fcmDataH(u16 DataLen, u8 * Data)
{
	TRACE((1,"Dato recibido"));
	adl_fcmSendData(Handle, Data, DataLen);
	//adl_fcmSendData(Handle, "ensayo", 7);
	return TRUE;
}