Modem keeps resetting

I have the following code on my module, Wavecom Fastrack supreme 10. Why does the module keep resetting at the write code line…

#include "adl_global.h"
#include "wm_uart.h"
const u16 wm_apmCustomStackSize = 1024;
static psGItfCont_t uart_if;
static u32 uart1_hdl;

sUartSettings_t settings;
sUartLc_t    line_coding;

void adl_main ( adl_InitType_e  InitType )
{
   line_coding.valid_fields = UART_LC_ALL;
       line_coding.rate = (eUartRate_t)( UART_RATE_USER_DEF | 2400 );
       line_coding.stop = UART_STOP_BIT_1;
       line_coding.data = UART_DATALENGTH_8;
       line_coding.parity = UART_PARITY_NONE;

       //uART2 opened in null modem role/ synchronous read, write
       settings.identity = "UART1";
       settings.role = UART_ROLE_NM;
       settings.capabilities = NULL;
       settings.event_handlers = NULL;
       settings.interface = &uart_if;
       settings.line_coding=&line_coding;

       uart1_hdl = adl_OpenDevice( DF_UART_CLID, &settings );
       if ( !uart1_hdl )
       {
           // UART2 opening failed
           return;
       }

          uart_if->write( uart1_hdl, "Tx some bytes",13 );  <---this line does not work
      

}

Hiya,

Try explicitly testing that the uart1_hdl variable is greater or equal to zero. Wavecom use negative handle values to indicate error conditions. Your code just checks that the value is not zero. I know that you have taken the example from the doco - but that doesn’t mean that it’s right :frowning:

Try something like this:

uart1_hdl = adl_OpenDevice( DF_UART_CLID, &settings );
       if ( uart1_hdl > 0 )
       {
       uart_if->write( uart1_hdl, "Tx some bytes",13 );  <---this line does not work
       }
       else
       {
           // UART2 opening failed
           return;
       }

Hiya,

Try explicitly testing that the uart1_hdl variable is greater than zero. Wavecom use negative handle values to indicate error conditions. Your code just checks that the value is not zero. I know that you have taken the example from the doco - but that doesn’t mean that the example is right :frowning:

Try something like this:

uart1_hdl = adl_OpenDevice( DF_UART_CLID, &settings );
       if ( uart1_hdl > 0 )
       {
           uart_if->write( uart1_hdl, "Tx some bytes",13 );  <---this line does not work
       }
       else
       {
           // UART1 opening failed
           TRACE (( "UART1 Open Failed. handle returns %d", uart1_hdl ));
           return;
       }

The other thing to do is to check the value of InitType as provided by adl_Main() - this will crudely let you know if you get a reboot because of an exception or a watchdog timeout…

ciao, Dave