# Modem keeps resetting

**URL:** <https://forum.sierrawireless.com/t/modem-keeps-resetting/4008>\
**Category:** Open AT\
**Created:** [December 21, 2009, 8:33am UTC](https://forum.sierrawireless.com/t/modem-keeps-resetting/4008 "2009-12-21T08:33:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shafeer](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shafeer](https://forum.sierrawireless.com/u/Shafeer)\
**Post date:** [December 21, 2009, 8:33am UTC](https://forum.sierrawireless.com/t/modem-keeps-resetting/4008/1 "2009-12-21T08:33:28Z")

</div>

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

```auto
#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
      

}
```

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [December 21, 2009, 10:47am UTC](https://forum.sierrawireless.com/t/modem-keeps-resetting/4008/2 "2009-12-21T10:47:42Z")

</div>

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 ☹

Try something like this:

```auto
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;
       }
```

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [December 21, 2009, 10:50am UTC](https://forum.sierrawireless.com/t/modem-keeps-resetting/4008/3 "2009-12-21T10:50:01Z")

</div>

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 ☹

Try something like this:

```auto
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
