Hi,
I’m traing to understend the sample about using UART, but I can’t.
Can someone write for me a sample how to get data from uart2 (9600 8n1 null modem) and send it to uart 1 or restore in some variable.
THX
Piotrek
Hi,
I’m traing to understend the sample about using UART, but I can’t.
Can someone write for me a sample how to get data from uart2 (9600 8n1 null modem) and send it to uart 1 or restore in some variable.
THX
Piotrek
Which particular sample?
Where are you stuck?
This sample is “UART raw access v6.31”
I stuck, becouse I don’t know how the AT+WDU put parameters to configure UART, and how to change it to configure UART without AT+WDU.
I think that sample in version 6.02 will be helpful, but a can’t find it.
Unless you have a very specific reason for using the “raw” UART access, I would strongly recommend that you don’t!
Use FCM instead if at all possible!
OK, but it is posible to configure UART2 to using 2-wire (null modem) with 8N1??
Yes.
Check AT+IFC and AT+ICF in the AT Commands Manual…
Hi
I found working example on this forum to use UART2, but I don’t known how to get data on request.
Is it only one way to get data fron UART2 by using
uart_handler=adl_fcmSubscribe ( ADL_FCM_FLOW_V24_UART2, (adl_fcmCtrlHdlr_f) tec_CtrlHandler, (adl_fcmDataHdlr_f) tec_DataHandler );
?
“my code”
#include "adl_global.h"
#include "adl_fcm.h"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;
bool tec_CtrlHandler(u8 event);
bool tec_DataHandler(u16 datlength,u8* data);
bool ipr_rsphdl (adl_atResponse_t *Params);
s8 uart_handler;
ascii NewText[20],txt[1000]];
/***************************************************************************/
/* Uart Callbacks */
/***************************************************************************/
bool tec_CtrlHandler(u8 event){
switch(event){
case ADL_FCM_EVENT_FLOW_OPENNED:
adl_atCmdCreate("AT+IPR=9600;&w", ADL_AT_PORT_TYPE ( ADL_PORT_UART2, ADL_AT_RSP ),(adl_atRspHandler_t)ipr_rsphdl,NULL);
adl_atSendResponse ( ADL_AT_UNS, "\r\nUART2 HAS BEEN OPENNED");
adl_fcmSwitchV24State(uart_handler,ADL_FCM_V24_STATE_DATA);//to receive data
break;
case ADL_FCM_EVENT_FLOW_CLOSED:
adl_atSendResponse ( ADL_AT_UNS, "\r\nUART2 HAS BEEN CLOSED");
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
adl_atSendResponse ( ADL_AT_UNS, "\r\nALREADY IN DATA MODE");
break;
default:
adl_atSendResponse ( ADL_AT_UNS, "\r\nUNKNOWN EVENT OCCURED");
break;
}
return TRUE;
}
// this is to read data.
bool tec_DataHandler(u16 datlength,u8* data)
{
u16 i;
for ( i = 0 ; i < datlength ; i++ )
{
txt[i]=data[i];
// wm_sprintf ( NewText, "%c", txt[i] );
//adl_atSendResponse(ADL_AT_UNS, NewText);//to send received data and display using uart1.
}
return TRUE;
}
bool ipr_rsphdl(adl_atResponse_t *Params)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nIN IPR RESPONSE HANDLER");
return TRUE;
}
// main function
void adl_main(adl_InitType_e InitType)
{
if(adl_fcmIsAvailable( ADL_FCM_FLOW_V24_UART2)==TRUE)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nIN MAIN FUNCTION\n");
uart_handler=adl_fcmSubscribe ( ADL_FCM_FLOW_V24_UART2, (adl_fcmCtrlHdlr_f) tec_CtrlHandler, (adl_fcmDataHdlr_f) tec_DataHandler );
}
else
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nUART2 IS NOT AVAILABLE");
}
}
Have you actually read the FCM documentaion in the ADL User Guide
Yes, I read this document, but I didn’t faind any clear explain how to get data from UART2.
Could You explain me it, or better, could You show me some example how to do this?
Data received by the UART is passed to the Data Handler - which you specify in your FCM subscription.
Hi!, i have a similar question aobut this. Is there any way to manage the Baudrate, Parity and Stop Bits using FCM?. Because if you use FCM you can´t control those parameters.
Thanks!!
No; FCM does not control those things - you have to use AT Commands.
Hi,
If You look upper You will see message from awneil where Hi wrote:
In my post You can faind exsample where is setting the speed for UART2 using AT command from aplication.
adl_atCmdCreate("AT+IPR=9600;&w", ADL_AT_PORT_TYPE ( ADL_PORT_UART2, ADL_AT_RSP ),(adl_atRspHandler_t)ipr_rsphdl,NULL);
In similar way You can send AT+IFC or AT+ICF to set parameters for UART.
Thanks to both of you, ill try this way. I have a FCM library created and running, ill let you know if it works!. Then ill post a complete solution to make a solid UART handler. Thanks again!.
I really dont understand how this works. My wavecoms is sendig data to the host (My CPU), to a Hiperterminal opened at 115200 bps, and the Wavecoms is setting to 9600bps and the host can readit. So, i assume that Wavecoms is changing the baudrate to 115200bps, but how could it know??, the host never send to the Wavecoms any data so this one should know wich baudrate is the right one.
Thanks!
If You could, past Your code and then we will see.