Skip to content

CircuitPython UART readline drops LF and returns None for blank lines #318

Open

Description

@YashAnand69

pslab.bus.busio.UART.readline() on main 08de0d0 consumes the LF byte before adding it to the returned data. A received blank line (b"\n") therefore returns None, just like a read timeout; b"hello\r\n" returns b"hello\r".

The method documents a line ending in a newline, matching CircuitPython UART.readline. pySerial also includes the LF terminator, allowing callers to distinguish a complete line from a partial timeout result.

I reproduced this through the real UART status/read command path with controlled firmware replies and a controlled clock, without physical hardware. Five cases fail on unchanged main: blank LF, ordinary LF, CRLF, binary data followed by LF, and successive-line framing. Five controls for timeout, partial lines, raw reads, readinto and zero-length reads pass.

I would like to fix this by appending the received byte before testing for the line terminator. The local fix passes all ten cases and 33 existing hardware-independent tests, configured source lint, wheel/sdist builds and Sphinx documentation. It leaves constructor/parity handling, polling and partial-timeout behavior unchanged; this is separate from #317.

AI assistance: Codex helped investigate the contract, prepare the minimal fix and run command-level tests. No physical UART integration test is claimed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions