Re: Help required on reading UART device and print on console

Erwan Gouriou

To answer your initial question, below example should work
   struct device *uartGPS;
   uartGPS = device_get_binding(CONFIG_UART_STM32_PORT_1_NAME);

    while (1) {
        unsigned char recvChar;
        while (uart_poll_in(uartGPS, &recvChar) < 0)
        printk("%c", recvChar);

Besides, for the device tree issue, please see my answer in
Patch is provided, we'll see if we upstream it.


On 9 May 2017 at 15:30, Erwan Gouriou <erwan.gouriou@...> wrote:
Hi Dhamu,

I saw the task you entered in Jira afterwards and now better understand your question.
Indeed, you might need additional settings to get these ports working:
One point is that you should activate them in dts files and nucleo_l476rg_defconfig.
Also, please check that GPIO ports are activated according to your pinmuxing.
I'll have a check and get back to you.

A sample test was present some time ago, but it has been moved to tests section and now is more adapted to extensive testing rather than simple (re-)use.
Re-instanciating a basic serial sample might indeed be a good idea.


On 9 May 2017 at 15:12, Dhamodharan Krishnan <dhamukrish@...> wrote:
Thanks Erwan for your reply.

Basically, I was able to use UART2 without any issue. But I have GPS and GSM modules which are serial device and hence need UART1 and 3 apart from UART2 for fetching and processing the data.

Would be very helpful if any example or advise much appreciated.


On 09-May-2017, at 12:48 PM, Erwan Gouriou <erwan.gouriou@...> wrote:

Hi Digidhamu,

If you're trying to use default UART (through ST link USB port) on nucleo_l476rg, you should use UART_2.


On 6 May 2017 at 09:53, Dhamodharan Krishnan <dhamukrish@...> wrote:

I am a day old since I started in Zephyr and from Arduino background. Could you please help with an example how to read from UART ports which are from 

Here is the code I have tried but failed.

#include <zephyr.h>
#include <misc/printk.h>
#include <uart.h>

int main(void) {

struct device *uartGPS;
uartGPS = device_get_binding(UART_1);

while (1) {
unsigned char* msg;
uart_poll_in(uartGPS, msg);

printk("%s", msg);


Zephyr-devel mailing list

Join to automatically receive all group messages.