Page 1 of 1

printf \r no output in ESP-IDF Monitor

Posted: Tue Mar 22, 2022 10:10 am
by george.stefanovski
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

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

Posted: Tue Mar 22, 2022 8:06 pm
by chegewara
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.

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

Posted: Wed Mar 23, 2022 1:11 am
by ESP_Sprite
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.

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

Posted: Wed Mar 23, 2022 5:47 am
by george.stefanovski
Thank you