← index #6978Issue #1293
Related · medium · value 0.969
QUERY · ISSUE

rp2: uasyncio: sys.stdout not working

openby zsquarepluscopened 2021-03-02updated 2024-09-13
port-rp2needs-info

the Pico port does not have a separate USB_VCP object so we resort to use sys stdio. while receiving works, transmitting blocks or crashes on writing. other ports like the pyboard support this. It would be good if this works so that uasyncio communication can be done via USB too.

Here is a minimal example for testing:
echo.py.txt

  • It works on a pyboard (pybv11-20210302-unstable-v1.14-82-gcdaec0dca)
  • It works on the unix port (though with sys.stdout instead of sys.stdout.buffer)
  • It fails on the pico (rp2-pico-20210301-unstable-v1.14-82-gcdaec0dca)
  • [edit] it fails on the esp32 (esp32-20210302-unstable-v1.14-82-gcdaec0dca)

Output when it fails (drain never outputs anything on pico and esp32):

# ready
.# input b'hello\r\n'
# drain
.........Traceback (most recent call last):
[...]
KeyboardInterrupt: 

And there is an exception on the pico (not on esp32) when the feedback_task is not started, pressing RETURN twice results in:

# ready
# input b'hello\r\n'
# drain
Traceback (most recent call last):
  File "<stdin>", line 32, in <module>
  File "<stdin>", line 29, in echo
  File "uasyncio/core.py", line 1, in run_forever
  File "uasyncio/core.py", line 1, in run_until_complete
IndexError: empty heap

Compared to an output on the pyboard, where it echoes and goes back to reading as expected:

# ready
...# input b'hallo\r\n'
# drain
.hallo
# ready
[...]
CANDIDATE · ISSUE

esp8266: can't read from sys.stdin

closedby deshipuopened 2015-05-28updated 2016-05-06
ports

I was trying to work around the fact that the ESP8266 port doesn't have UART support on the Python side yet, and simply read/write from and to the sys.stdin and sys.stdout.

While sys.stdout works as expected, trying to read even a single character from sys.stdin hangs the REPL. I compared with other ports, and that's not the case in them -- they wait until the specified number of characters is input and then properly return those characters.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied