Micropython automatically converting stdin carriage returns to newlines? #9758
-
I was looking to modify some terminal code (specifically, aiorepl)to make it work nicely with windows clients and encountered this issue. When I press enter in a windows terminal, MicroPython (v1.19.1 on a Raspberry Pi Pico) appears to recieve 2 linefeed characters (0x0A + 0x0A) instead of a carriage return then a linefeed (0x0D + 0x0A). Code:
Run the code, connect to port using a modified PuTTY configured to send a CRLF, hit enter and you get: I get similar results when using the Thonny Shell or the REPL shell included in the Micropython plugin for PyCharm. Am I doing something wrong here or is this a quirk (or bug) with MicroPython? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, MicroPython translates You can try using |
Beta Was this translation helpful? Give feedback.
Yes, MicroPython translates
\r
to\n
(and I think this even follows how CPython works).You can try using
sys.stdin.buffer.read(1)
, that will not do any translation.