# UART raw access Sample

**URL:** <https://forum.sierrawireless.com/t/uart-raw-access-sample/4128>\
**Category:** Development tools\
**Created:** [January 24, 2010, 9:40am UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128 "2010-01-24T09:40:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haiden](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Haiden](https://forum.sierrawireless.com/u/Haiden)\
**Post date:** [January 24, 2010, 9:40am UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/1 "2010-01-24T09:40:52Z")

</div>

Hi there,

I am trying to get the UART access sample going with my FASTRACK Supreme 20. I am using latest M2MStudio and USB card for additional Serial port access. I am connecting from M2MStudio to FASTRACK on USB serial connection and trying to open UART1 with “AT+WDU=1,UART1,115200”. M2MStudio Trace shows following lines:

ADL 1 uart\_open(UART1,115200)  
ADL 1 Uart\_Open : ERROR UART is not opened

I am wondering why I can’t open UART1. I tried other scenarios like tracing M2MStudio on COM1 and trying to open the UART1 or UART3. Neither one worked. I am using the sample as it is.

Any help is appreciated.

Thanks,  
Haiden

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [January 24, 2010, 4:18pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/2 "2010-01-24T16:18:00Z")

</div>

> [@Haiden](#):
>
> ADL 1 Uart\_Open : ERROR UART is not opened

You have the source code - look at it to determine what could cause that particular Trace to be emitted…

---

<div class="post-metadata">

**Author:** ![Haiden](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Haiden](https://forum.sierrawireless.com/u/Haiden)\
**Post date:** [January 25, 2010, 4:55pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/3 "2010-01-25T16:55:23Z")

</div>

Sure. I did. Nothing looks suspicious. Following is the code. My earlier post showed first and last trace statements from the following code snippet. All the settings look just fine. I am trying to open UART1, so the role is UART\_ROLE\_DCE. Speed is 115200. M2MStudio can use the UART1 just fine for debugging. So when I flip the COM port and make M2MStudio use UART3 based on USB and try to let my app open UART1, i get the error.

I am working with only one app (UART\_access) and trying to open UART1 for the first time. Bad part is, error code on Open fail is not descriptive other than fail/success. Is it possible that UART1 is already opened by something in the OS or Firmware? If yes, how can I disable it from using UART1?

```auto
TRACE (( 1, "uart_open(UART%c,%d)",identity[4], speed ));
   /* Device */
   Settings.capabilities = NULL;
   Settings.identity = identity;
   Settings.role = ( UART2 == identity[4] ) ? UART_ROLE_NM : UART_ROLE_DCE;
   /* Events */
   events.user_data = (void*)0;
   events.valid_cb = UART_CB_ON_ALL;
   memcpy((u8*)events.cb_list, (u8*)uartCbTab, 6*sizeof(sGCbDesc_t));
   Settings.event_handlers = &events;

   /* To retrieve the UART SP Interface */
   Settings.interface = &pinterface;

   /* Line Coding */
   lc.valid_fields = UART_LC_ALL;
   lc.rate = (eUartRate_t)(UART_RATE_USER_DEF | speed );
   lc.stop = UART_STOP_BIT_1;
   lc.parity = UART_PARITY_NONE;
   lc.data = UART_DATALENGTH_8;

   Settings.line_coding = &lc;

   /*------------------*/
   /* open UART device */
   /*------------------*/
   if( 0 < (handle = adl_OpenDevice( DF_UART_CLID, &Settings)) )
   {
      TRACE(( 1, "UART successfully opened" ));

      /* Locally store the uart interface */
      uart_itf = *pinterface;

      /* Flow control IO control setting */
      Fc.op = G_IOC_OP_SET;
      Fc.type = UART_FC_RTS_CTS;

      if( uart_itf.io_control( handle, IOC_UART_FC, (void*) &Fc) )
      {
         uart_itf.close( handle );
         TRACE((1, "ERROR : IOCTL FC Set"));
         handle = 0;
      }
   }
   else
   {
      TRACE(( 1, "Uart_Open : ERROR UART is not opened" ));
   }
```

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [January 25, 2010, 6:57pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/4 "2010-01-25T18:57:36Z")

</div>

> [@Haiden](#):
>
> Is it possible that UART1 is already opened by something in the OS or Firmware?

I’ve just tried it, and yes - that looks likely!

I don’t use the “Target Management” in M2MStudio (as it is officially acknowledged to be a steamy pile of the smelly stuff) - I’m sticking with the old Target Monitoring Tool (TMT) and Terminal Emulator (TE) instead.

Anyhow, I have TMT+TE connectcted to a Fastrack Supreme on UART1, and tried to open UART2 with this sample app:

> [@](#):
>
> at+wdu=1,UART2,9600
> 
> ERROR

much as you got?

So I tried “disabling” UART2 first:

> [@](#):
>
> [b]AT+WMFM=0,0,2
> 
> OK  
> at+wdu=1,UART2,9600
> 
> OK[/b]

and the TRACE said:

> [@](#):
>
> 39079.601 Trace ADL 1 +WDU Command Handler  
> 39079.601 Trace ADL 1 uart\_open(UART2,9600)  
> 39079.601 Trace ADL 1 UART successfully opened

I guess this is what the ADL User Guide is referring to when it says:

> [@ADL User Guide for Open AT® OS v6.21](#):
>
> A UART service provider handled by the Wavecom firmware is not available for an Open AT® application.
> 
> A UART service provider handled by an Open AT® application is not available for the Wavecom firmware.
> 
> In both previous cases, an attempt to get access to an already used UART service provider returns an error to the requestor.

But that’s about as clear as mud!

I presume that, “handled by the Wavecom firmware” is supposed to mean that it’s “opened” by AT+WMFM ❓  
But that is not at all clear, and there is no proprer explanation nor specific mention of AT+WMFM 😠

There is also no mention of this in the documention of AT+WMFM in the AT Commands manual 😠

And the worst thing by far is that there is no explanation nor even any mention of this in the Sample! 😠😠

---

<div class="post-metadata">

**Author:** ![Haiden](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Haiden](https://forum.sierrawireless.com/u/Haiden)\
**Post date:** [January 25, 2010, 7:55pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/5 "2010-01-25T19:55:31Z")

</div>

That is great help. If this is true, How can I execute this command from my app before it tries to open the UART?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [January 25, 2010, 8:42pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/6 "2010-01-25T20:42:12Z")

</div>

> [@Haiden](#):
>
> How can I execute this command from my app

Note that you can never execute a custom AT command from your own Open-AT application!

[viewtopic.php?f=36&t=3764&p=14592&hilit=execute+custom+at+command#p14592](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=36&t=3764&p=14592&hilit=execute+custom+at+command#p14592)  
[viewtopic.php?f=3&t=3936&p=15472&hilit=execute+custom+at+command#p15445](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=3&t=3936&p=15472&hilit=execute+custom+at+command#p15445)

But, if you mean, “how can I use this facility on the same UART from which I issue the command” - then, I guess, you would have to modify the sample so that it closes the UART (with AT+WMFM) before it attempts to open it with adl\_OpenDevice()…

[viewtopic.php?f=21&t=4510&p=18187#p18187](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=21&t=4510&p=18187#p18187)

---

<div class="post-metadata">

**Author:** ![fedex\_03](https://avatars.discourse-cdn.com/v4/letter/f/f17d59/32.png) [@fedex\_03](https://forum.sierrawireless.com/u/fedex_03)\
**Post date:** [October 12, 2016, 12:22pm UTC](https://forum.sierrawireless.com/t/uart-raw-access-sample/4128/7 "2016-10-12T12:22:15Z")

</div>

Hi there,

I need help to solve a problem regarding the UART raw access.

I have a SiWi GL6100 with only one uart, specifically the UART1.

With this uart I program the module and the I switch the module to FCM mode to read data from UART1.

Now I want to use the UART in raw mode and this is what i do:  
[_] Enable FCM mode to enable to read ESC character from serial. If I detect this character switch to AT mode to update the firmware through UART1.  
[_] After 10 second switch UART1 to AT Mode and then disable UART1 with this command:

```auto
sprintf(atCommand, "AT+WMFM=0,0,1,0");
adl_atCmdCreate( atCommand, UART_1, ( adl_atRspHandler_t )EvhConfUartx, NULL);
```

But when the firmware execute the command I give back an error:

```auto
+CME ERROR: 3
```

The same thing appears if I execute the command through terminal monitor, but this behaviour is explained in tha AT command manual:

> [@](#):
>
> Only the remote UART can be opened or closed (it is impossible to close UART1 sending  
> WMFM command trough UART1)

. This make sense.

Where I make an error?

Thanks in advance!
