Skip to content

Add break support - #148

Open
Happyfield7 wants to merge 2 commits into
puddly:devfrom
Happyfield7:add-break-support
Open

Happyfield7 wants to merge 2 commits into
puddly:devfrom
Happyfield7:add-break-support

Conversation

@Happyfield7

Copy link
Copy Markdown
Contributor

Problem

A break holds the TX line low for longer than one character, which writing data cannot do. Devices and serial buses use it as a signal outside the data stream: to wake or reset the other side, or to mark where a frame starts. serialx cannot send one yet, so pyserial code that calls send_break() or sets break_condition fails on serialx and serialx-compat.

Change

  • BaseSerial gains break_condition, set_break_condition() and send_break(duration=0.25) with pyserial's names; BaseSerialTransport and AsyncSerial gain async set_break_condition() and send_break().
  • POSIX uses TIOCSBRK/TIOCCBRK. Python's termios lacks them, so the numbers are hardcoded per platform (generic Linux, BSDs and Linux SPARC); ENOTTY raises UnsupportedSetting.
  • Windows uses SetCommBreak/ClearCommBreak, RFC 2217 sends SET_CONTROL break on/off, and Web Serial uses setSignals({break}).
  • Socket and ESPHome cannot carry a break and raise UnsupportedSetting.
  • Like pyserial, a break does not drain pending output first and is not cleared on close(). A cancelled async send_break() releases the break.

Testing

  • New sync/async transport tests (with a NO_BREAK quirk for socket and ESPHome), mocked ioctl and Win32 tests, async cancellation and close tests, and compat tests.
  • Test suite on Linux, macOS, Windows and Pyodide; no new findings from ruff, mypy, pylint or codespell. The com0com pair tests were not run locally.
  • On an FT232R adapter on a single-wire bus, a held break arrives as a 00 byte and the line returns to normal afterwards, on Linux, macOS and Windows.

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.59%. Comparing base (2c500d7) to head (85d7f31).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #148      +/-   ##
==========================================
+ Coverage   94.38%   94.59%   +0.20%     
==========================================
  Files          25       25              
  Lines        4437     4532      +95     
==========================================
+ Hits         4188     4287      +99     
+ Misses        249      245       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant