RP2: Get read buffer size / partial read on USB stdin
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.
rp2: uart.read() never returns
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.