# Can't find UART output

**URL:** <https://mangoh.discourse.group/t/cant-find-uart-output/353>\
**Category:** Uncategorized\
**Created:** [January 26, 2017, 8:51pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353 "2017-01-26T20:51:33Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [January 26, 2017, 8:51pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/1 "2017-01-26T20:51:33Z")

</div>

Hello All,

I am attempting to output data to the UART-1 Port but I can’t see any output. I am using Uart-1 because this port should by default be connected to IoT Connector #0. From what I see on the schematic I should see the output on pins 12 and 13. This translate to column P3 the inner column and row 2 and 3.

```
P2 P3 

```

29 10 | 11 28  
30 09 | 12 27  
31 08 | 13 26  
32 07 | 14 25  
33 06 | 15 24  
34 05 | 16 23  
35 04 | 17 22  
37 03 | 18 21

I have set the UART to run the customer linux application:  
microcom -E /dev/ttyAT  
AT!MAPUART=17,1

But with all this I still can not see any output. I have included my code below, it is an adaptation from timerLed.

```
 int open_port(void)
{
  int fd; /* File descriptor for the port */
  fd = open("/dev/ttyHSL1", O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd == -1)
  {
  /*
  * Could not open the port.
  */
    perror("open_port: Unable to open /dev/ttyHSL1 - ");
  }
  else
     fcntl(fd, F_SETFL, 0);

  return (fd);
}

//--------------------------------------------------------------------------------------------------
/**
 * Main program starts here
 */
//--------------------------------------------------------------------------------------------------

COMPONENT_INIT
{
LE_INFO("===============blinking LED application has started");

ConfigureLed();
//TODO: All code gets run from here:
int uart_fd = open_port();
int n = write(uart_fd, "ATZ\r", 4);
if (n < 0)
    fputs("write() of 4 bytes failed!\n", stderr);

LE_INFO("=====================================================");
LE_INFO("=====================================================");
LE_INFO("=====================================================");
LE_INFO("Attempt to output to UART produces: %d", n);
LE_INFO("=====================================================");
LE_INFO("=====================================================");
LE_INFO("=====================================================");

le_timer_Ref_t ledTimerRef = le_timer_Create("LED Timer");
le_timer_SetMsInterval(ledTimerRef, LED_SAMPLE_INTERVAL_IN_MILLISECONDS);
le_timer_SetRepeat(ledTimerRef, 0);
le_timer_SetHandler(ledTimerRef,ledTimer);
le_timer_Start(ledTimerRef);

}

```

In my adef I have included:

```
requires:
{
    device:
    {
         [rw] /dev/ttyHSL1 /dev/ttyHSL1 
    }
}

```

Any help would be very much appreciated.

Thanks  
Kas

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [January 26, 2017, 9:21pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/2 "2017-01-26T21:21:00Z")

</div>

I should also mention that if I try use HSL0 instead of HSL1 the program will not run. When I try manually start the program I get a message “Application ‘timerLed’ is not installed”. I can remove the program but trying to install it again produce teh same results.

I have tried with sandbox set to both true and false with no difference in the result.

Anyhelp would be great.  
Kas

---

<div class="post-metadata">

**Author:** ![Raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Raf](https://mangoh.discourse.group/u/Raf)\
**Post date:** [January 26, 2017, 11:12pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/3 "2017-01-26T23:12:31Z")

</div>

Hi @Kas.Lewis

HSL1 is UART 2 (defaults to Linux console). You’re after HS0 (not HSL0) - a bit confusing I know.

Change to this in your .c file.

```auto
  fd = open("/dev/ttyHS0", O_RDWR | O_NOCTTY | O_NDELAY);

```

And add this to your .adef file

```auto
        // Get read and write access to the UART1 port.
        [rw] /dev/ttyHS0 /dev/ttyHS0

```

Lastly, you may also need to enable UART 1 on IoT#0 using the `muxCtrlService` (from your app) or the `mux` command line tool. I believe the command is `mux 1`

Cheers,  
Raf

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [January 27, 2017, 2:26am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/4 "2017-01-27T02:26:58Z")

</div>

Hello @Raf,

I have tried HS0 as you suggested but I still don’t see any output. With regards to using the mux I’m not 100% sure how to do that. I will see if I can find anything on the forums to help with that.

I do have another question. On page 27 of the Developers Guide, it seems to show the default connection from UART1 is to IoT connector #0. If my understanding is correct I should see an output on the IoT breakout board without changing the mux settings.

Thankfully  
Kas

---

<div class="post-metadata">

**Author:** ![Raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Raf](https://mangoh.discourse.group/u/Raf)\
**Post date:** [January 27, 2017, 4:22am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/5 "2017-01-27T04:22:29Z")

</div>

Hi @Kas.Lewis

One thing I noticed in your code is that you never set the port attributes after opening it. I.E. baud rate, mode (raw or canonical), flow control. Though I suspect the lack of output has more to do with the mux settings.

Here’s a snippet of code I’ve used to run a serial port @ 115200 baud in ‘raw’ mode which you can use to get you started:

```auto
int SetPortSettings(int fd)
{
	struct termios tp;
	int ret;

	ret = tcgetattr(fd, &tp); // get the current settings before modifying them
	if (ret < 0)
	{
		perror("tcgetattr");
	}

	cfsetspeed(&tp, B115200); // 115200 baud
	cfmakeraw(&tp); // raw mode

	tp.c_cc[VMIN] = 0; // non-blocking reads
	tp.c_cc[VTIME] = 5; // 5x 10ms inter-character timeout

	tp.c_cflag &= ~CSTOPB;
	//tp.c_cflag &= ~CRTSCTS; // HW flow control OFF
	tp.c_cflag |= CRTSCTS; // HW flow control ON
	tp.c_cflag |= CLOCAL | CREAD;

	ret = tcsetattr(fd, TCSANOW, &tp);	// set the new settings
	if (ret < 0)
	{
		perror("tcsetattr");
	}

	ret = tcflush(fd, TCIOFLUSH); // flush i/o buffers
	if (ret < 0)
	{
		perror("tcflush");
	}

	return ret;
}

```

Check out these two links for more info on configuring port settings:  
[https://www.cmrr.umn.edu/~strupp/serial.html#2\_54](https://www.cmrr.umn.edu/~strupp/serial.html#2_54)  
[http://www.tldp.org/HOWTO/text/Serial-Programming-HOWTO2](http://www.tldp.org/HOWTO/text/Serial-Programming-HOWTO2)

It’s true that the default connection for UART1 is on IoT#0 (dip switch 6 on SW401). However, I also found that it was necessary to explicitly enable UART 1 on IoT#0 from the mux control app. It was my experience after running my own test out of curiosity. I was able to get an output on IoT#0.

Here’s a quick test you can run from the command line while ssh’d into the mangOH without the need for an app to confirm UART operation:

1. ssh into mangOH
2. type the command: `mux 1`  
_this enables UART1 on IoT slot 0_
3. type the command: `stty -F /dev/ttyHS0 -cooked`  
_this sets /dev/ttyHS0 to ‘raw’ mode (uncooked)_
4. type the command: `microcom -E /dev/ttyHS0 -s 115200`  
_this opens /dev/ttyHS0 @115200 baud_
5. start typing characters and you should observe the data on the IoT UART pins

If you still don’t see any output, try changing the position of dip switch 6 on SW401.

See how you go with this.

Cheers,  
Raf

 ![](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/2990c824dd898a4adb7b656b551c9fe37746c9b7.png)

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [January 31, 2017, 8:55pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/6 "2017-01-31T20:55:14Z")

</div>

Hello @Raf,

I have tried the quick test you mentioned but have had no luck:

> [@Raf](#):
>
> 1. ssh into mangOH2) type the command: mux 1this enables UART1 on IoT slot 02) type the command: stty -F /dev/ttyHS0 -cookedthis sets /dev/ttyHS0 to ‘raw’ mode (uncooked)3) type the command: microcom -E /dev/ttyHS0 -s 115200this opens /dev/ttyHS0 @115200 baud4) start typing characters and you should observe the data on the IoT UART pins
> 
> If you still don’t see any output, try changing the position of dip switch 6 on SW401.

I used a scope on the IoT board looking at the pins mentioned. I also looked at CN600 pin 7. I moved SW401 switch 6 both on and off and still no success. IF there are any further suggestions I would be happy to hear them.

Thanks  
Kas

---

<div class="post-metadata">

**Author:** ![Raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Raf](https://mangoh.discourse.group/u/Raf)\
**Post date:** [February 1, 2017, 1:37am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/7 "2017-02-01T01:37:36Z")

</div>

Hi @Kas.Lewis

Sorry to hear that didn’t work for you.  
Did you get a ‘Success’ message when executing `mux 1`?

Note that you should be looking on `Pin 9` at `CN600` for _output_ from the modem.  
Similarly, look on the pin labeled `RXD` on the IoT pin-out the image above.

The labels on the schematic refer to the client-side (not the modem), I.E. from the perspective of a device connected to the modem. So, RX is actually the devices receive line (modem’s transmit line) and vice-versa.

Also, you probably already know this, but the voltage levels are 1.8V. Set the scope to trigger accordingly (falling-edge).

Raf

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [February 1, 2017, 9:06am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/8 "2017-02-01T09:06:58Z")

</div>

Hi Kas,

Can you open an at port and run at!mapuart? command?

Regards,  
Ashish

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [February 1, 2017, 1:04pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/9 "2017-02-01T13:04:32Z")

</div>

Hello @asyal,

Results from running the command are:

root@swi-mdm9x15:~# microcom -E /dev/ttyAT  
at!mapuart?  
!MAPUART: 17,16

OK

Kas

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [February 1, 2017, 1:51pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/10 "2017-02-01T13:51:06Z")

</div>

Ok, you’re settings look ok. Did you check as Raf as asked on pin 9 of cn600?

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [February 1, 2017, 2:23pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/11 "2017-02-01T14:23:22Z")

</div>

I did try looking at all the pins on CN600 previously with a scope. I don’t recall seeing anything when using microcom. When running my code I saw something but maybe only 2 bytes, not the 4 that I am sending (“ATZ\r”).

Looking at Raf’s comment my understanding is that I cannot use a CP2102 serial to USB adapter. The CP2102 needs a logic high \> 2.00V but the mangOH outputs a high of 1.8V. If you could confirm my understanding that would be helpful.

Kas

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [February 1, 2017, 9:53pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/12 "2017-02-01T21:53:20Z")

</div>

you can use a cp2104 (1.8V IO) serial to usb adapter not cp2102.

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [February 2, 2017, 2:03am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/13 "2017-02-02T02:03:27Z")

</div>

![](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/90323a2e7e406bbd83ab01b88dce89226a734dfe.png)

Hello @asyal, @Raf,

Above is a screenshot from my testng. During this testing I had my scope connected to the IoT breakout board at the TXD and the RXD and nothing was detected on either line (The slope was set to 1V/Div, Horizontal 1s/Div).

It appears the issue is the two fold. Firstly my scope does not have a high enough resolution display (TBS 1202B-EDU). So while I was hoping to see some spikes even on a low resolution (large time base) the display could not display them. Moving to a smaller time base (25us/Div) and using the trigger I was able to capture the serial data. Also attaching my logic analyzer (Saleae Original Logic) I was able to capture everything. The captured data includes the output from the program even without any setup (Default is 9600 baud).

The second issue is the logic levels. Using a CP1202 or other serial to USB converters I was expecting levels of \> 2.0V for a high. Knowing now that I need a converter that can read a logic high of 1.8V the regular serial to USB converters will give you a false negative. They will insist no data has been received because in fact the logic levels they require where not met. Moving to a CP1204 as @asyal suggests would resolve this issue.

Hopefully I can keep moving forward for full communication over UART. BTW is there anyway to change the logic levels, on the MangOH board without using an external level shifter.

Thanks  
Kas

---

<div class="post-metadata">

**Author:** ![Raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Raf](https://mangoh.discourse.group/u/Raf)\
**Post date:** [February 2, 2017, 2:30am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/14 "2017-02-02T02:30:46Z")

</div>

Hi @Kas.Lewis

Good to see the issue has been isolated. I too use a Saleae Logic analyzer for all my debugging. I swear by them - they’re a great tool and have saved me many countless hours of head banging/scratching.

I don’t believe there is a way change the logic levels on the WP8548 GPIO. You’ll need the external hardware level shifters.

Are you wanting to communicate with a PC over UART from mangOH?  
You could enable User Linux Application mode on UART2 (you’d lose the console ability, though).

```
microcom -E /dev/ttyAT
AT!MAPUART=17,2

```

UART2 (`/dev/ttyHSL1`) has a RS-232 Transceiver IC. You could plug the DB9 straight into a PC or use a USB to RS-232 adaptor cable.

If anything, it might serve as means to get your program working, then switch over to `/dev/ttyHS0` once you resolve the level shifting.

Cheers,  
Raf

---

<div class="post-metadata">

**Author:** ![Kas.Lewis](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kas.Lewis](https://mangoh.discourse.group/u/Kas.Lewis)\
**Post date:** [February 2, 2017, 2:42am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/15 "2017-02-02T02:42:26Z")

</div>

Thank you both @Raf and @asyal for you help it has really helped me move along.

I am trying to talk to an MCP39F511 from Microchip. The idea is to monitor power consumption and then upload the data to AirVantage. As I cannot yet use AirVantage (wrong SIM card, Freedom Mobile AKA Wind Mobile doesn’t work with the module) I am starting here and hopefully will be able to use WiFi to talk to Airvantage later or I’ll borrow a SIM for a while to get that portion working.

Thanks  
Kas

---

<div class="post-metadata">

**Author:** ![kalaivani](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/kalaivani/32/2183_2.png) [@kalaivani](https://mangoh.discourse.group/u/kalaivani)\
**Post date:** [March 17, 2021, 6:25pm UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/16 "2021-03-17T18:25:54Z")

</div>

hi when i give mux 1 i get message as mux not found in mangohred board, could you guide me

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 18, 2021, 12:36am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/17 "2021-03-18T00:36:12Z")

</div>

the schematic is different, seems there is no mux chipset in mangoh red.  
You can compare the schematic.

---

<div class="post-metadata">

**Author:** ![kalaivani](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/kalaivani/32/2183_2.png) [@kalaivani](https://mangoh.discourse.group/u/kalaivani)\
**Post date:** [March 18, 2021, 4:58am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/18 "2021-03-18T04:58:35Z")

</div>

can you guide me how to communicate with RS232 via UART , any sample code availble, in Red board any changes to be done??? how to check whether Rs232 UArt is communicating via command in terminal

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 18, 2021, 5:30am UTC](https://mangoh.discourse.group/t/cant-find-uart-output/353/19 "2021-03-18T05:30:42Z")

</div>

You can see here

[https://source.sierrawireless.com/resources/airprime/application\_notes\_and\_code\_samples/airprime\_wp\_series\_and\_fx30\_uart\_to\_tcp\_app/](https://source.sierrawireless.com/resources/airprime/application_notes_and_code_samples/airprime_wp_series_and_fx30_uart_to_tcp_app/)
