printf \r no output in ESP-IDF Monitor

george.stefanovski
Posts: 2
Joined: Mon Apr 26, 2021 10:43 am

printf \r no output in ESP-IDF Monitor

Postby george.stefanovski » Tue Mar 22, 2022 10:10 am

Hello,

Using the ADC DMA example (https://github.com/espressif/esp-idf/tr ... c/dma_read)

I am trying to get the output (within the ESP-IDF Monitor) to display on the same line i.e. no output on a new line.

I have tried using the \r carriage return format specifier, but output happens.

  1. for (int i = 0; i < ret_num; i += ADC_RESULT_BYTE)
  2.             {
  3.                 adc_digi_output_data_t *p = (void *)&result[i];
  4.                 printf("value %d\r", p->type1.data);
  5.                 fflush(stdout)

Thank you in advance
George Stefanovski

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: printf \r no output in ESP-IDF Monitor

Postby chegewara » Tue Mar 22, 2022 8:06 pm

Its annoying, but for some reason print requires "\n" to flush to console.
You could use uart_write_bytes instead, but that requires to init and install UART port.

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: printf \r no output in ESP-IDF Monitor

Postby ESP_Sprite » Wed Mar 23, 2022 1:11 am

I think that's standard posix behaviour... you may be able to use fflush(stdout) to flush the line, or use setvbuf() to make stdout unbuffered.

george.stefanovski
Posts: 2
Joined: Mon Apr 26, 2021 10:43 am

Re: printf \r no output in ESP-IDF Monitor

Postby george.stefanovski » Wed Mar 23, 2022 5:47 am

Thank you

Who is online

Users browsing this forum: amiral and 67 guests