Page 1 of 1

Reading from STDIN never returns any data

Posted: Fri Mar 13, 2026 7:07 am
by greggles
Hello,

Using a variant "waveshare_esp32_s3_touch_amoled_241" I'm not have any success trying to read characters from stdin.

Starting with the "hello_world_main" example from ESP IDF, the following has been added as a task during the countdown:

Code: Select all

void reader( void *pvParameters ) {
    printf("Reader . . \n");
    while ( 1 ) {
        char ch = getchar();
        if ( ch < 255 ) {
            printf("Read %c %d\n", ch, ch );
        }
        vTaskDelay(5);
    }
}
The line "Reader . ." is displayed, but then 255 is only ever returned by "getchar()", even with copious ponding on the serial console keyboard.



--

Re: Reading from STDIN never returns any data

Posted: Fri Mar 13, 2026 8:19 am
by nopnop2002

Code: Select all

#include <stdio.h>
#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"

static const char *TAG = "MAIN";

void app_main()
{
    printf("Reader . . \n");
    while ( 1 ) {
        char ch = getchar();
        if ( ch < 255 ) {
            printf("Read %c %d\n", ch, ch );
        }
        vTaskDelay(5);
    }
}
This code works correctly.
Reader . .
Read 1 49
Read 2 50
Read 3 51
Read 4 52
Read 5 53
Read 6 54

Re: Reading from STDIN never returns any data

Posted: Fri Mar 13, 2026 8:51 am
by greggles
I tried your code complete, and again for me it's not indicating any data being received (I tried with both "screen" and "idf.py montitor"). The output of the ESP32 is displayed, but data sent to the ESP32 is not received.

That is puzzling.

What ESP32 are you using?

The Waveshare board being used as GPIO 19 and 20 connected directly to a USB-C port.

"idf.py flash" works, so it must be a configuration issue? :?

Re: Reading from STDIN never returns any data

Posted: Sat Mar 14, 2026 10:43 am
by nopnop2002
The Waveshare board being used as GPIO 19 and 20 connected directly to a USB-C port.

This setting is required for USB Serial/JTAG Controller Console.

Re: Reading from STDIN never returns any data

Posted: Sat Mar 14, 2026 11:49 am
by greggles
Thank you! I must have missed than nuance in the documentation.

Image