UART DTR Signal Event capture

UART DTR Signal Event capture

Postby eddie435 » Fri May 08, 2009 9:31 pm

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...

Code: Select all
//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
eddie435
 
Posts: 19
Joined: Tue Jan 15, 2008 10:05 pm
Has thanked: 0 time
Have thanks: 1 time

Re: UART DTR Signal Event capture

Postby awneil » Sat May 09, 2009 6:22 am

Presumably not your problem here, but:
eddie435 wrote:
Code: Select all
   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;
   }


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:
Code: Select all
if( result < OK )
User avatar
awneil
 
Posts: 6603
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 85 times

Re: UART DTR Signal Event capture

Postby eddie435 » Tue May 12, 2009 1:11 pm

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
eddie435
 
Posts: 19
Joined: Tue Jan 15, 2008 10:05 pm
Has thanked: 0 time
Have thanks: 1 time

Re: UART DTR Signal Event capture

Postby eddie435 » Wed May 13, 2009 10:33 pm

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

Does anyone have any ideas???
eddie435
 
Posts: 19
Joined: Tue Jan 15, 2008 10:05 pm
Has thanked: 0 time
Have thanks: 1 time

Re: UART DTR Signal Event capture

Postby eddie435 » Fri May 22, 2009 6:54 pm

With the help of Wavecom I was able to figure it out. I used adl_portSubscribe() and adl_portStartSignalPolling()
It's working great.
eddie435
 
Posts: 19
Joined: Tue Jan 15, 2008 10:05 pm
Has thanked: 0 time
Have thanks: 1 time

Re: UART DTR Signal Event capture

Postby yyiu002 » Tue Feb 23, 2016 4:23 am

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
yyiu002
 
Posts: 21
Joined: Mon May 20, 2013 6:05 pm
Has thanked: 2 times
Have thanks: 0 time


Return to Archive

Who is online

Users browsing this forum: No registered users and 1 guest