Skip to content

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

Merged
dpgeorge merged 1 commit intomicropython:masterfrom
mvds00:pullreq3
Nov 3, 2023
Merged

ports/rp2/machine_uart.c: fix handling of serial break condition#12787
dpgeorge merged 1 commit intomicropython:masterfrom
mvds00:pullreq3

Conversation

@mvds00
Copy link
Copy Markdown
Contributor

@mvds00 mvds00 commented Oct 24, 2023

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.

@mvds00 mvds00 force-pushed the pullreq3 branch 3 times, most recently from 154f3f2 to 20e6592 Compare October 24, 2023 08:35
Comment thread ports/rp2/machine_uart.c
@mvds00
Copy link
Copy Markdown
Contributor Author

mvds00 commented Nov 2, 2023

@robert-hh are there issues that need to be addressed?

@robert-hh
Copy link
Copy Markdown
Contributor

You have to wait, until the maintainer has time for it. That may take a while.

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.

Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
@dpgeorge
Copy link
Copy Markdown
Member

dpgeorge commented Nov 3, 2023

This looks good to me. A break condition on the UART line is definitely not the same as a NUL character, so the break should be handled differently.

@dpgeorge dpgeorge merged commit d95f5aa into micropython:master Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants