Page 1 of 1

Non blocking console/keyboard input

Posted: Fri Nov 09, 2018 7:46 am
by uCTRL
For ESP32 Uart console/keyboard input.

Basically, need advice for non-blocking keyboard input from Uart console port, as scanned 1 character at the time.
input() and sys.stdin are blocking.

Thanks

Re: Non blocking console/keyboard input

Posted: Fri Nov 09, 2018 9:08 am
by pythoncoder
In general UARTS can operate in a non-blocking mode by using uasyncio StreamReader and StreamWriter objects. See the tutorial in this repo.

Re: Non blocking console/keyboard input

Posted: Fri Nov 09, 2018 9:39 am
by uCTRL
Thanks Peter

I would also like to know if there is a simpler system call to access existing OS keyboard scan.

Re: Non blocking console/keyboard input

Posted: Sat Nov 10, 2018 10:47 am
by pythoncoder
In general (and in particular on the ESP32) MicroPython runs on bare metal. There is no OS. If you want to connect a serial keyboard to an ESP32 you will need to interpret the data yourself. Unless someone has already posted code to do this.