I want to do some simple async input via UART_0 and pass that through to other UARTs. Instead of doing scanf or getc, can I simply read UART_0 or will that cause core to crash since some other task is probably monitoring UART_0 and I suspect read and write on uarts are not thread safe (and shouldn't be anyway).
I would like to read stdin without having to hit enter, in case you wonder why I wanted to do this.
Thanks.
Getting input from console by reading UART_0
Re: Getting input from console by reading UART_0
int ch = fgetc(stdin);
Re: Getting input from console by reading UART_0
Thanks Mike!
I just tried getchar(). It looks like getchar() does NOT block execution so I can get characters in real time but if I copy/paste, it is too fast to catch all characters. I have a 100ms delay in the loop that catches the characters. Isn't there a buffer for console input?
Will getc(stdin) have a buffer but then has to wait for enter? I'll try and post back.
I just tried getchar(). It looks like getchar() does NOT block execution so I can get characters in real time but if I copy/paste, it is too fast to catch all characters. I have a 100ms delay in the loop that catches the characters. Isn't there a buffer for console input?
Will getc(stdin) have a buffer but then has to wait for enter? I'll try and post back.
Re: Getting input from console by reading UART_0
No, getc() also doesn't seem to be buffered. I copy and pasted 14 bytes of text to console, and esp32 got about 8. Why is it not buffered?
Re: Getting input from console by reading UART_0
You need to create your own buffering scheme. There is an example of this in the examples directory.
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot] and 146 guests