← index #6851PR #12787
Related · high · value 4.957
QUERY · ISSUE

read() & readline() on rp2 port don't work/work as expected

openby uksconeopened 2021-02-05updated 2021-02-13
port-rp2

the UART on the rp2 port mostly works. read([num of bytes]) works mostly as expected although it seems to drop bytes occasionally and "hangs" if you try to read more bytes than currently available however read() with no number of bytes to read set and readline() just sit there indefinitely. I suspect it's to do with the fact that timeout isn't implemented

CANDIDATE · PULL REQUEST

ports/rp2/machine_uart.c: fix handling of serial break condition

mergedby mvds00opened 2023-10-24updated 2023-11-03
port-rp2

The FIFO reports not only the bytes read, but also 4 error bits. These were not checked, leading to NUL value read in case of break and possible garbage bytes being written on parity/framing error.

This patch addresses the issue that NUL bytes are incorrectly read on break, and at least provides the boilerplate code and comments for error handling, that may be implemented in the future. This patch only addresses the rp2 port, but it is likely other ports are also affected by this bug. I am willing to look into that once this PR is accepted.

Note that there are interesting things that can be done with break conditions (e.g. automatically splitting read data on them and/or signalling break to data consuming code), but the first thing is to have at least these error flags checked.

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