Page 1 of 1
Weird fgets and gets behavior
Posted: Wed Sep 12, 2018 2:45 pm
by fly135
Was trying to use fgets or gets for user input. The functions don't wait for a newline. They seem to time out in about a sec and return whatever characters were typed.
Re: Weird fgets and gets behavior
Posted: Wed Sep 12, 2018 3:00 pm
by fly135
Looks like you have to implement your own version of the function using getchar. Which is non blocking as well and will return immediately. So you need to put a sleep/delay in whenever you don't get a char.
Re: Weird fgets and gets behavior
Posted: Wed Sep 12, 2018 3:05 pm
by ESP_igrr
By default, reading from stdin is non-blocking. If you install the UART driver, you should be able to do blocking reads. Please see examples/system/console for an example of how to enable blocking reads from stdin. Also please see
https://docs.espressif.com/projects/esp ... out-stderr
Re: Weird fgets and gets behavior
Posted: Wed Sep 12, 2018 4:33 pm
by fly135
Oh cool! Thanks for the info.
John A