Hi ,
I have problem with UART. When I try to send string from q2406B to PC(Hyperterminal) via RS 232 port, then I found the problem. I can’t receive anything. I’m sending my code below:
#include “adl_global.h”
#include “adl_fcm.h”
#include “adl_at.h”
u32 wm_apmCustomStack[256];
const u16 wm_apmCustomStackSize = sizeof(wm_apmCustomStack);
bool MyCtrlHandler(u8 Event){
switch(Event){
case ADL_FCM_EVENT_FLOW_OPENNED:
{
// Related to adl_fcmSubscribe
adl_atSendResponse(ADL_AT_UNS, “\r\nADL_FCM_EVENT_FLOW_OPENED\r\n”);
TRACE ((1, “ADL_FCM_EVENT_FLOW_OPENED”));
}
break;
case ADL_FCM_EVENT_FLOW_CLOSED:
{
// Related to adl_fcmUnsubscribe
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_FLOW_CLOSED\r\n");
TRACE ((1, "ADL_FCM_EVENT_FLOW_CLOSED"));
}
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
{
// Related to adl_fcmSwitchV24State
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_V24_DATA_MODE\r\n");
TRACE ((1, "ADL_FCM_EVENT_V24_DATA_MODE"));
}
break;
case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
{
//
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_V24_DATA_MODE_EXT\r\n");
TRACE ((1, "ADL_FCM_EVENT_V24_DATA_MODE_EXT"));
}
break;
case ADL_FCM_EVENT_V24_AT_MODE:
{
// Related to adl_fcmSwitchV24State
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_V24_AT_MODE\r\n");
TRACE ((1, "ADL_FCM_EVENT_V24_AT_MODE"));
}
break;
case ADL_FCM_EVENT_V24_AT_MODE_EXT:
{
//
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_V24_AT_MODE_EXT\r\n");
TRACE ((1, "ADL_FCM_EVENT_V24_AT_MODE_EXT"));
}
break;
case ADL_FCM_EVENT_RESUME:
{
// Related to adl_SendDate and adl_fcmSendDataExt
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_RESUME\r\n");
TRACE ((1, "ADL_FCM_EVENT_RESUME"));
}
break;
case ADL_FCM_EVENT_MEM_RELEASE:
{
// Related to adl_SendDate and adl_fcmSendDataExt
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_FCM_EVENT_MEM_RELEASE\r\n");
TRACE ((1, "ADL_FCM_EVENT_MEM_RELEASE"));
}
break;
}
return TRUE;
}
bool MyDataHandler(u8 Event){
switch(Event){
case ADL_FCM_EVENT_FLOW_OPENNED:
{
// Event when flow is redy to process
adl_atSendResponse(ADL_AT_UNS, “\r\nEvent when flow is redy to process\r\n”);
TRACE ((1, “Event when flow is redy to process” ));
}
break;
case ADL_RET_ERR_PARAM:
{
// One parameter has an incorrect value
adl_atSendResponse(ADL_AT_UNS, "\r\nOne parameter has an incorrect value\r\n");
TRACE ((1, "One parameter has an incorrect value" ));
}
break;
case ADL_RET_ERR_ALREADY_SUBSCRIBED:
{
// The flow is not available
adl_atSendResponse(ADL_AT_UNS, "\r\nThe flow is not available\r\n");
TRACE ((1, "The flow is not available" ));
}
break;
case ADL_RET_ERR_NOT_SUBSCRIBED:
{
// V24 subscription is made when V24 Master flow is not subscribed
adl_atSendResponse(ADL_AT_UNS, "\r\nV24 subscription is made when V24 Master flow is not subscribed\r\n");
TRACE ((1, "V24 subscription is made when V24 Master flow is not subscribed" ));
}
break;
case ADL_FCM_RET_ERROR_GSM_GPRS_ALREADY_OPENNED:
{
// GSM or GPRS subscription is made when the other one is already
adl_atSendResponse(ADL_AT_UNS, "\r\nGSM or GPRS subscription is made when the other one is already\r\n");
TRACE ((1, "GSM or GPRS subscription is made when the other one is already" ));
}
break;
case ADL_RET_ERR_BAD_STATE:
{
// The required Uart flow was not previously opened with the AT+WMFM command
adl_atSendResponse(ADL_AT_UNS, "\r\nThe required Uart flow was not previously opened with the AT+WMFM command\r\n");
TRACE ((1, "The required Uart flow was not previously opened with the AT+WMFM command" ));
}
break;
}
return TRUE;
}
void Cmd_Handler(adl_atCmdPreParser_t *paras){
switch(paras->Type){
case ADL_CMD_TYPE_TEST:
{
adl_atSendResponse(ADL_AT_UNS, “\r\nADL_CMD_TYPE_TEST\r\n”);
}
break;
case ADL_CMD_TYPE_READ:
{
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_CMD_TYPE_READ\r\n");
}
break;
case ADL_CMD_TYPE_PARA:
{
adl_atSendResponse(ADL_AT_UNS, "\r\nADL_CMD_TYPE_PARA\r\n");
}
}
}
void adl_main (adl_InitType_e InitType){
// u8 * PacketToSend;
s8 sFcmReturn;
s8 FCM_Handler;
//static const ascii * PacketToSend = “PING”;
u8 * PacketToSend = “PING”;
u16 size;
FCM_Handler = adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1, MyCtrlHandler, MyDataHandler);
adl_atSendResponse(ADL_AT_UNS, "\r\nUART - Flow Control Management\r\n");
// Switch to data mode
adl_fcmSwitchV24State(FCM_Handler, ADL_FCM_V24_STATE_DATA);
TRACE ((1, "UART - Flow Control Management"));
TRACE ((1, __DATE__));
TRACE ((1, __TIME__));
size = sizeof(PacketToSend) + 1;
/* Send packet */
sFcmReturn = adl_fcmSendDataExt(FCM_Handler, PacketToSend, size);
if (sFcmReturn < OK){
TRACE((1, "Problem to send the packet"));
adl_atSendResponse(ADL_AT_UNS, "\r\nCannot send the packet\r\n");
}
else{
/* OK */
TRACE((1, "Packet Sent"));
adl_atSendResponse(ADL_AT_UNS, "OK");
}
adl_fcmUnsubscribe(FCM_Handler);
}
Can you help me to solve my problem? Thank you in advanced!
Best Regards,
belikg