getchar() or similar?

al3x-h
Posts: 3
Joined: Thu Jun 15, 2017 10:44 pm

getchar() or similar?

Postby al3x-h » Tue Jul 11, 2017 5:48 am

Hi, I need to a function to block until the user hits the keyboard. From my brief search, it seems like

Code: Select all

getchar/fgets
are good candidates. I've had little success with

Code: Select all

getchar
and

Code: Select all

fgets
even though the code compiles, it seems like they don't really work. I notice that stdin has been redirected, so in theory

Code: Select all

getchar
should work? Has anyone been able to get any of the stdin functions to work? Or is there a way to make API calls for UART0 (which I believe is used for printf) so I can use the USB-Serial interface on my dev board?

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

Re: getchar() or similar?

Postby ESP_Sprite » Tue Jul 11, 2017 8:45 am

If I recall correctly, standard serial IO is non-blocking on the ESP32, meaning getchar() always immediately returns. Is that what you're seeing?

Who is online

Users browsing this forum: No registered users and 73 guests