Reading from STDIN never returns any data

greggles
Posts: 5
Joined: Fri Mar 13, 2026 6:37 am

Reading from STDIN never returns any data

Postby greggles » Fri Mar 13, 2026 7:07 am

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.



--

nopnop2002
Posts: 347
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Reading from STDIN never returns any data

Postby nopnop2002 » Fri Mar 13, 2026 8:19 am

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

greggles
Posts: 5
Joined: Fri Mar 13, 2026 6:37 am

Re: Reading from STDIN never returns any data

Postby greggles » Fri Mar 13, 2026 8:51 am

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? :?

nopnop2002
Posts: 347
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Reading from STDIN never returns any data

Postby nopnop2002 » Sat Mar 14, 2026 10:43 am

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.
Attachments
getchar.jpg
getchar.jpg (130.88 KiB) Viewed 131 times

greggles
Posts: 5
Joined: Fri Mar 13, 2026 6:37 am

Re: Reading from STDIN never returns any data

Postby greggles » Sat Mar 14, 2026 11:49 am

Thank you! I must have missed than nuance in the documentation.

Image
Attachments
Screenshot 2026-03-14 at 10.46.00 pm.png
Screenshot 2026-03-14 at 10.46.00 pm.png (12.04 KiB) Viewed 111 times

Who is online

Users browsing this forum: ChatGPT-User and 10 guests