Question about change speed in V24 serial data mode

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?

Hello,
I’m also using a Fastrack to communicate to a modbus device using the stardard RS232 port at 9600 bps. Basically, I’ve done the same thing you explain (didn’t look deep into your code).
In remote mode, using the OpenAT debugging tools and VS 6.0 the program seems to work, but when I download it to the Fastrack and let it run standalone, the Fastrack was not talking with the device. The reason is that it is not really changing speed to 9600 bps.
It is really fustrating, because once connected to the device there is no way to know what’s really going on.
To realize what was going on I needed to develop an emulator and run it in a PC connected to the modem.

To solve the problem the only solution I’ve found is to manually send the commands from hyperterminal and make the configuration permanent:
AT+IPR=9600
AT&W

If anyone has a clue, please let us know

Hi,

I think you should use the ADL_AT_PORT_TYPE macro to send the +IPR command, as it was done in this post:

http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=445

I don’t think it will work without this. (I am not sure if it is really required to close the port before the AT+IPR, I think AT&W should be just fine…)

Best Regards,
Jan

HI

1th step:
Be aware of subscription to timer in order to process the adl_CmdCreate() because you subscribe to it after it was already processed and maybe can cause interference with the subscription to the flow which is your second step.

2nd step:
Take care after opening the flow to DATA MODE because you are using the adl_atSendResponse() and it is forbidden.