← index #8772Issue #6998
Related · high · value 0.930
QUERY · ISSUE

RP2: Get read buffer size / partial read on USB stdin

openby smurfixopened 2022-06-17updated 2023-06-06
enhancement

I want to run a binary protocol on the RP2's USB port. The problem is that I have no way to determine how many characters are available, reading more than what's available blocks, and reading one at a time ends up being too slow.

The UART has a nice any() function that tells me how many characters are in the buffer. I'd like to request adding that method to its stdin handler, or a way to tell it to not block on partial reads, or both.

CANDIDATE · ISSUE

rp2: uart.read() never returns

closedby kevinkk525opened 2021-03-05updated 2021-03-11
port-rp2

In the current implementation calling uart.read() without an expected amount of bytes will never return.
Expected behaviour: As soon as some data was read, that data should be returned.

In https://github.com/micropython/micropython/pull/6870 @robert-hh states:

When uart.read() is called without an argument, the size at the machine_uart_read() is 256.

However, I can't reproduce that. Sending over 400 Bytes in small batches or a big one still doesn't return anything.

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