About os.dupterm readinto() method #11600
-
https://github.com/boochow/FBConsole Like this repo,we can redirect repl by using os.dupterm,by the method write(),we can get the repl print and redirect to screen. In docs,it says: So,how to use readinto() the change repl input source from UART0 RX to other source? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You need to write a stream object that returns input from your keyboard device. It can just ignore anything that's written to it. The idea is that the REPL is duplicated to multiple streams (e.g. UART, keyboard, framebuffer, BLE, etc). Each one just implements what makes sense -- UART & BLE do both input and output, framebuffer does just output, keyboard does just input. |
Beta Was this translation helpful? Give feedback.
Here is an example (based on https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_uart_repl.py) that runs on a Pyboard and generates an "A" each time the pyboard's button is pressed.
Your code will need to do something different to get the key events, but ultimately implement read/readinto to return characters in a similar way.