I was looking to modify some terminal code to make it portable and 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:
import sys
while(True):
b = sys.stdin.read(1)
sys.stdout.write("(" + hex(ord(b)) + ")")
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?