Send data fromQ2686 to microncontroller through uart2

Hi,
I have written a code to send the data on Q2686 uart2 to the micro controller .
The below is the code which I have written to send the data.
bool BaudDisplayHandler(adl_atResponse_t *respr)
{
char *s;

unsigned char  sig;
s= respr->StrData;

TRACE (( 1, "Inside BaudDisplayHandler" ));
TRACE (( 1, s ));
//TRACE (( 1, "%d", strlen(s) ));


return FALSE;

}
Main(){

adl_atCmdCreate(“AT+WMFM=0,1,2”, ADL_AT_PORT_TYPE(ADL_PORT_UART1, FALSE), BaudDisplayHandler, “*”, NULL);
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,“Embedded Application : Main”);
adl_atCmdCreate(“at+ipr=9600”, ADL_AT_PORT_TYPE(ADL_PORT_UART2, FALSE), (adl_atRspHandler_t)NULL, NULL);

u8 dummy;
adl_fcmSendData(dummy,”TESTING UART2 SEND FUNCTION\n”,29);

}

But Its not sending any data .
Pls help me to fix this problem.

thanks & regards
ravee

What makes you think that this should work at all??

What does the ADL User Guide tell you about the parameters than adl_fcmSendData requires??

Hi,
I went through user guide and implemented all required functions for uart.But still i’m unable to receive the data,
Here is my newly written code.

/***********************************************************************************
AFTER OPENING THE UART,STATUS ARE DISPLYED HERE
***********************************************************************************/
bool fcmcontrolhandler2(adl_fcmEvent_e event)
{
switch(event)
{
case ADL_FCM_EVENT_FLOW_OPENNED:
if(adl_fcmSwitchV24State(fcmhandler2,ADL_FCM_V24_STATE_DATA)==OK)
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"uart flow is opened successfully\n ");
break;
case ADL_FCM_EVENT_FLOW_CLOSED:
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,“uart flow is closed\n”);
break;

case ADL_FCM_EVENT_V24_DATA_MODE:
	 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Switched to DATA mode\n");
	 break;

case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
	 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Switched to DATA mode by Ext App\n");
	 break;

case ADL_FCM_EVENT_V24_AT_MODE:
	 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Switched to AT mode sucessfully\n");
	 break;

case ADL_FCM_EVENT_V24_AT_MODE_EXT:
	 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Switched to AT mode by Ext App\n");
	 break;

case ADL_FCM_EVENT_RESUME:
	 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Resumed\n");
	 break;

default:
	adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Not received\n");
}

return TRUE;
}

/***********************************************************************************
READ THE DATA FROM UART
***********************************************************************************/
bool fcmdatahandler2(u16 datalen,u8 *data)
{

adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"In reading the data\n");

}
bool BaudDisplayHandler(adl_atResponse_t *respr)
{
char *s;

unsigned char  sig;
s= respr->StrData;

TRACE (( 1, "Inside BaudDisplayHandler" ));
TRACE (( 1, s ));
//TRACE (( 1, "%d", strlen(s) ));


return FALSE;

}
Main(){
s8 fcmevnt;
adl_atCmdCreate(“AT+WMFM=0,1,2”, ADL_AT_PORT_TYPE(ADL_PORT_UART1, FALSE), BaudDisplayHandler, “*”, NULL);
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,“Embedded Application : Main”);
adl_atCmdCreate(“at+ipr=9600”, ADL_AT_PORT_TYPE(ADL_PORT_UART2, FALSE), (adl_atRspHandler_t)NULL, NULL);

fcmevnt=adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART2,fcmcontrolhandler2,fcmdatahandler2);
adl_fcmSendData(fcmevnt,”TESTING UART2 SEND FUNCTION\n”,29);

}

pls help to fix this probelm

thanks
ravee

It is a fundamental principle of good programming practice that a variable’s name should be descriptive of the variable’s purpose - so why have you called this “event” ?

It’s not an event, is it?

A second principle is that you should always check the return value from a function when it might indicate an error.

There’s no point in continuing blindly after the adl_fcmSubscribe call if that call failed and has given you an error code describing the failure!

Again, this function gives a return value indicating success or failure - use it!!

At the very least, you should TRACE the return values…

Hi,
I’m using Uart2 fcm function to receive the data from other device , I’m facing simple problem at the Rx buffer of of data handler ,

At a time it can receive only 56 bytes , I want to increase this to ablest 70 bytes so that it will reduce my code complexity .
I searched in ADL user guide for q2686 but could not get the information
pls let me know if it is possible increase the length , becoz maximum data i’ll be receiving is 60 bytes at a time . If we cant increase i’ll go with arbitrary-sized “fragments” …

rgds
Ravee

You can’t.

Your code must cope with the data being delivered in arbitrarily-sized “fragments”

No - it isn’t, I’m afraid.

Yes - that is what you have to do!

This isn’t really any different from programming a “normal” buffered UART in a “normal” microcontroller.

Or even on a PC…

See: FCM Newby - #5 by awneil

Hi,
Thanks for the reply … I implemented arbitrarily-sized “fragments” and I could receive the the data .

Now I’m facing simple problem at the string handling ,

In my application I receive 65 bytes(5 bytes header and 15 bytes data of four sensor node -> 15x4+5=65) character data from uart …Once I receive the data I need to parse that and put it standard format and send to the server , i.e I receive the sensor data I need to put their uint ,ID, and value in predefined format and send ,.
to do this I have done the following format .
static u8 send_buffer[];// buffer needs to be send
u8 sen_ID[5][30]={ " first sensor"," second sensor", / * it goes till the fourth sensor
u8 sen_unit[5][30]={ " first sensor"," second sensor", / * it goes till the fourth sensor .
/* and values are extracted from the uart buffer*/ and stored in u8 sen_data[5][20]

/* to frame the final format I’m doing the following */

for(i=0;i<4;i++)
{

stract(send_buffer,sen_ID[i]);
stract(send_buffer,sen_data[i]);
strcat(send_buffer,sen_unit[i]);

}

// after this i’m wip write to send the data

But the problem is device is getting restarted once its processing the above strings,.what is the problem , what are the possible ways to handle the string … pls help

regards
Ravee

This is a basic ‘C’ error - nothing specifically to do with SiWi or Open-AT.

Have you thought how you would do this on a “normal” microcontroller?

You haven’t specified the size of your buffer; effectively, this just defines a pointer!

Note that sending all those strings is a grossly inefficient use of the bandwidth.
That may not matter to you (at the moment), but a more compact format would generally be more appropriate.

Also, as you’re sending to a server, it might be better to choose something that’s easier for a machine to parse…