UART DTR Signal Event capture

Hi all,

Can someone help me figure out whats worng with my code?

I’m trying to capture when the DTR signal from UART1 changes but haven’t been able to get it yet. See code below…

//UART1 - Capture Signal Changes

#include "adl_global.h"
#include "adl_OpenDevice.h"
#include "wm_uart.h"
#include "adl_traces.h"

static psGItfCont_t uart_if;
static u32 uart_hdl;

//static s32 EventHandle;

/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;

/***************************************************************************/
/*  Local functions                                                        */
/***************************************************************************/

/* callback declaration */
//static void uart_OnSigStateChange( void* user_data,  psUartCbOssc_t psSigState );

/***************************************************************************/
/* UART Callback                                                          */
/***************************************************************************/
void uart_OnSigStateChange (void* user_data,  psUartCbOssc_t psSigState)
{
	adl_atSendResponse(ADL_AT_RSP, "\r\nEVENT : SIG CHANGE delta   state \r\n");
    //adl_atSendResponse(ADL_AT_RSP, (char*)psSigState->delta );
    //adl_atSendResponse(ADL_AT_RSP, (char*)psSigState->state );

	TRACE ((1, "EVENT : SIG CHANGE delta %x  state %x",psSigState->delta,psSigState->state));
}

/***************************************************************************/
/*  Function   : adl_main                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application initialization                       */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilization                           */
/*--------------------+---+---+---+----------------------------------------*/
/*                    |   |   |   |                                        */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{

	TRACE (( 1, "My Tests Start" ));

	sUartSettings_t settings;
	sUartLc_t 		line_coding;
	sUartEvent_t    events;

	// Set the line coding parameters
	line_coding.valid_fields = UART_LC_ALL;
	line_coding.rate = (eUartRate_t)( UART_RATE_USER_DEF | 115200 );
	line_coding.stop = UART_STOP_BIT_1;
	line_coding.data = UART_DATALENGTH_8;
	line_coding.parity = UART_PARITY_NONE;

	/* Events */
	events.user_data = (void*)0;
	events.op = G_IOC_OP_GET;
	events.valid_cb = UART_CB_ON_SIG_STATE_CHANGE;
	events.cb_list[3].evt_hdl = (pGEvtNotif_t)&uart_OnSigStateChange ;
	//events.cb_list[3].user_data = (void*)0;

	// UART1 will be opened in DCE role
	settings.identity = "UART1";
	settings.role = UART_ROLE_DCE;
	settings.capabilities = NULL;
	settings.event_handlers = &events;
	settings.interface = &uart_if;
	settings.line_coding = &line_coding;

	// Open UART1
	adl_atSendResponse(ADL_AT_RSP, "\r\nTesting Start...\r\n");
	TRACE (( 1, "Opening UART1..." ));
	uart_hdl = adl_OpenDevice( DF_UART_CLID, &settings );
	TRACE (( 1, "UART return = %d", uart_hdl ));

	if( !uart_hdl )
	{
		// UART1 opening failed...
		adl_atSendResponse(ADL_AT_RSP, "\r\nUART Open Failed...\r\n");
		TRACE (( 1, "UART1 failed to open" ));
		return;
	}
	else
	{
		// UART1 successfully opened
		adl_atSendResponse(ADL_AT_RSP, "\r\nUART1 Opened Successfully...\r\n");
	}

}

Any help will be greatly appreciated. Thanks.

Eddie

Presumably not your problem here, but:

Note that the above test is incorrect!

A non-zero value for uart_hdl is not necessarily an error!

(unfortunately, this bad practice is illustrated in some of the Wavecom samples!)

The correct test for an error is:

if( result < OK )

Thanks awneil.

Still, I haven’t been able to capture the DTR signal change. Does anyone have any sample code or know someone who has been able to capture any signal changes (DTR, DCD, RTS, etc…) on the UART1? The documentation seem to say it can be done, but I haven’t had success yet. Any help is appreciated. Thanks.

Eddie

I’m trying to open UART1 in DCE role, but the returned handle value is -1

Does anyone have any ideas???

With the help of Wavecom I was able to figure it out. I used adl_portSubscribe() and adl_portStartSignalPolling()
It’s working great.

Are you able to monitor DTR pin change with these functions?
Checked enum defination for PIN:

typedef enum
{
ADL_PORT_SIGNAL_CTS,
ADL_PORT_SIGNAL_DSR,
ADL_PORT_SIGNAL_LAST
}adl_portSignal_e;

Thanks