Hi,
I’ m trying to connect the fastrack M1306B with a device through RS232 interface (SUB HD 15 pin )
This device work whit speed 9600 bps
In the other topics I have read that for esample it needs to follow steps :
“” 1. Send the AT+IPR command from the embedded application.
2. Wait for OK.
3. When OK is received, subscribe to a timer. This is to provide some time to the module to actually change the V24 serial speed.
4. When the timer expires (and you get a call to timer callback function), subscribe to FCM and then switch to data mode.
5. Change the baud rate of your external application (like hyperterminal) to the one that you have set using AT+IPR command. “”
This is the code :
#include "adl_global.h"
#include "adl_fcm.h"
/***************************************************************************
Mandatory variables
----------------------------------------------------------------------------
wm_apmCustomStack
wm_apmCustomStackSize
----------------------------------------------------------------------------
****************************************************************************/
u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
/***************************************************************************
Global variables
----------------------------------------------------------------------------
FCM_Handle : Handle returned by the adl_fcmSubscribe
command : Command typied by the use
com : Pointer for "command"
cont : Data Length of the command typied by the user
----------------------------------------------------------------------------
****************************************************************************/
u8 FCM_Handle;
// vector byte to send to the device
u8 command[] ={0x02,0x04,0x02,0x02,0x00,0x00,0xc4,0xc2,0x04,0x03};
/***************************************************************************
Function : FcmCtrlHandler
----------------------------------------------------------------------------
Description: Display the FCM Events
----------------------------------------------------------------------------
Variable Name |IN |OUT|GLB| Utilisation
----------------------+---+---+---+-----------------------------------------
Event | | | | FCM Events
----------------------+---+---+---+-----------------------------------------
****************************************************************************/
bool FcmCtrlHandler (adl_fcmEvent_e Event){
switch (Event){
case ADL_FCM_EVENT_FLOW_OPENNED:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_FLOW_OPENNED\n\r");
adl_fcmSwitchV24State(FCM_Handle,ADL_FCM_V24_STATE_DATA);
break;
case ADL_FCM_EVENT_FLOW_CLOSED:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_FLOW_CLOSED\n\r");
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_V24_DATA_MODE\n\r");
// Send vector bytes to device
adl_fcmSendData (FCM_Handle,&command,10);
cont=0;
break;
case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_V24_DATA_MODE_EXT\n\r");
break;
case ADL_FCM_EVENT_V24_AT_MODE:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_V24_AT_MODE\n\r");
adl_fcmSendData (FCM_Handle, "Nunes",5);
break;
case ADL_FCM_EVENT_RESUME:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_RESUME\n\r");
break;
case ADL_FCM_EVENT_MEM_RELEASE:
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_MEM_RELEASE\n\r");
break;
}
return TRUE;
}
/***************************************************************************
Function : FcmDataHandler
----------------------------------------------------------------------------
Description: Handle with the income data
----------------------------------------------------------------------------
Variable Name |IN |OUT|GLB| Utilisation
----------------------+---+---+---+-----------------------------------------
DataLen | | | | Length of "Data"
----------------------+---+---+---+-----------------------------------------
Data | | | | Data receveid
----------------------+---+---+---+-----------------------------------------
****************************************************************************/
bool FcmDataHandler (u16 DataLen, u8 * Data){
// when I will receive the data from the device they will be
// transmitted by TCP/IP
}
//the 4th step
void TimerHandler(u8 timerid){
FCM_Handle = adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1,FcmCtrlHandler,FcmDataHandler);
}
// the 2th and 3th step
bool CmdResp(adl_atResponse_t *paras){
if( !wm_strncmp(paras->StrData,"\r\nOK",4))
adl_tmrSubscribe(FALSE,30,ADL_TMR_TYPE_100MS,TimerHandler);
}
// the 1th step
void change_speed() {
adl_atCmdCreate("AT+IPR=9600",TRUE,CmdResp,"*",NULL);
}
/***************************************************************************
Function : SimCard
----------------------------------------------------------------------------
Description: Display the SimCard Events
----------------------------------------------------------------------------
Variable Name |IN |OUT|GLB| Utilisation
----------------------+---+---+---+-----------------------------------------
Event | | | | Sim Card Events
----------------------+---+---+---+-----------------------------------------
****************************************************************************/
void SimCard (u8 Event){
switch(Event){
//Normal Events
case ADL_SIM_EVENT_PIN_OK:
adl_atSendResponse ( ADL_AT_UNS, "PIN Code Ok\n\rConnectd...");
break;
case ADL_SIM_EVENT_REMOVED:
adl_atSendResponse ( ADL_AT_UNS, "SimCard Remove\n\r");
break;
case ADL_SIM_EVENT_INSERTED:
adl_atSendResponse ( ADL_AT_UNS, "SimCard Insert\n\r");
break;
case ADL_SIM_EVENT_FULL_INIT:
adl_atSendResponse ( ADL_AT_UNS, "Ok\n\r");
change_speed();
FCM_Handle = adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1,FcmCtrlHandler,FcmDataHandler);
break;
//Error Events
case ADL_SIM_EVENT_PIN_ERROR:
adl_atSendResponse ( ADL_AT_UNS, "PIN Code Error\n\r");
break;
}
}
/***************************************************************************
Function : adl_main
----------------------------------------------------------------------------
Description: Main function
----------------------------------------------------------------------------
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(SimCard,NULL);
}
My problem now is that for the moment I don’t know how to effect the
debug
Can you tell me if the code related to the change of speed is correct?