how to manage UART2?

Hi everybody

I am working on a developer Kit with a Q2426B module. There are two serial jacks and I want to be able to configure and turn UART2 ON. I know by default UART1 is open, so I used at+wmfm=0,1,2 to open the second, and then subscribed this way:

adl_atCmdCreate(“AT+WMFM=0,1,2”,FALSE,CMEECmdResp,"*",NULL);

adl_atCmdCreate( “AT+IPR=115200”, ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE), CMEECmdResp,"*", NULL );

adl_atCmdCreate( “AT+ICF=3,4”, ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE), CMEECmdResp, “*”, NULL );

adl_atCmdCreate( “AT+IFC=2,2”, ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE), CMEECmdResp,“OK”, NULL );

adl_atCmdCreate( “AT&W”,TRUE, CMEECmdResp, “*”, NULL );

U2_Handler = adl_fcmSubscribe ( ADL_FCM_FLOW_V24_UART2,MyCtHnd2,MydataHnd2);

but nothing happens in UART2. Is it necessary to have the serial cable connected to the RS232-2 jack?.

Do you have any idea? or if possible do you have any example.

Thanks in advance

Camilo.

Well now I have communication thru UART2 but It’s been impossible to switch to DATA MODE in UART2. It seems it never reaches the Control and Data Handlers when I subscribe to it, it only gives response to AT commands but never switch to DATA MODE.

Does anybody know how can I switch UART2 to DATA MODE.

Do I have to turn UART1 off?

Is it possible that the AT+WMFM=0,1,2 and adl_fcmSubscribe () API are causing interference each other, because nothing happens?

Thanks in advance,

Camilo Moreno.

How can I read from UART2? I just found senddata function, but I would like to read from uart2.

Your data handler ( e.g. bool fcmDataH( u16 DataLen, u8 *Data ) ) is called with the data and how much data there is. So there is no read function… You just process the data when your handler is called…

Best Regards,
Jan

Okay I found it. But what is the format of the u8 *Data? I try to write it on the terminal:

u8 result;
    ascii buf[100];
    char *msn;
    
    uzenet("<- Receive FCM2 Data Blocks");    
    wm_sprintf(buf, "d: %c\n\r", Data);
    msn = buf;
    adl_atSendResponse(ADL_AT_UNS, msn);

But I get strange characters. And if I write it on %d I get very big numbers. So Which is the format of the u8 Data, or how can I write it on the uart1?

u8 is “unsigned char”, so you should use %s. Also make sure that the string is \0 terminated before you are using wm_sprintf().

Best Regards,
Jan

Well I check my code and if I write the Datalen it says 0 but the handler was called. So what can I do?

void fcmDataH2 ( u16 DataLen, u8 * Data )
{
    u8 result;
    ascii buf[100];
    char *msn;
    
    
    
    uzenet("<- Receive FCM2 Data Blocks");    
    wm_sprintf(buf, "d: %s - %d\n\r", Data, DataLen);
    msn = buf;
    adl_atSendResponse(ADL_AT_UNS, buf);
    
}

Here is my code. I connect the uart2 via a bluetooth app. I reach the bluetooth module via bluetooth, and I connect there with a hyperterminal. This bluetooth module is connected the q2406b uart2 port. I switch the bluetooth modult serial port to data mode and the q2406b uart2 port too. And when I press a key in the hyperterminal the datahandler function is called because the text <- Receive FCM2 Data Blocks wrote on the wavecom modul uart1, but after d: there is nothing and the datalenght is 0. Whats wrong with my code? I set the baudrate before I switch to data mode so I think that isn’t the problem.