Skip to content

Fix flow_control: "software" enabling RTS/CTS instead of XON/XOFF - #758

Merged
puddly merged 2 commits into
devfrom
zigpy-bot/fix-software-flow-control
Sep 28, 2026
Merged

puddly merged 2 commits into
devfrom
zigpy-bot/fix-software-flow-control

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Fixes #752, and the "software" mapping reported in #709.

uart._connect() derives the serial port flags with if flow_control is None: XON/XOFF else: RTS/CTS, so "software" selects hardware flow control. This regressed in #595 (0.37.0) when bellows moved to zigpy's device schema: the old check was == CONF_FLOW_CONTROL_DEFAULT, and that default was "software", so "software" did mean XON/XOFF – and being the schema default at the time, it is still stored in a lot of long-lived EZSP config entries.

It stayed invisible on CH340 adapters because the Linux ch341 driver ignored CRTSCTS until 6.14 (commit 35478bc369a6); HAOS 18.x ships 6.18. CH340-based adapters running software-flow-control firmware (Elelabs ELU013/ELR023) now fail the EZSP reset: the RST frame is accepted by the kernel but apparently never transmitted, most likely because the bridge waits for CTS, which nothing on this firmware drives. Full analysis in #752.

"software" now means xonxoff=True, rtscts=False, and only "hardware" enables RTS/CTS. None is unchanged; whether it should mean "no flow control" (as #709 suggested) is a separate decision.

Anyone storing "software" for an adapter that really does use RTS/CTS firmware reverts to the pre-0.37.0 XON/XOFF behaviour, as does the CLI, whose --flow-control default is software (its help text also claimed "use hardware flow control" and is corrected). The UART connect test now asserts the flags for all three values; the "software" case fails on dev.

Since #595, `uart._connect` treated every non-`None` `flow_control` value
as hardware flow control, so `"software"` opened the serial port with
`rtscts=True`. This was harmless as long as the USB-serial driver ignored
`CRTSCTS`, but Linux 6.14 added real RTS/CTS support to the `ch341`
driver, and CH340-based adapters running software-flow-control firmware
(e.g. Elelabs ELU013/ELR023) now time out during the ASH reset because
the bridge waits for CTS.

Map `"software"` to XON/XOFF and only enable RTS/CTS for `"hardware"`.
`None` keeps XON/XOFF enabled, as before. Assert the resulting serial
port flags in the UART connect test and fix the CLI help text.
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.55%. Comparing base (15ccb49) to head (c57d68b).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #758      +/-   ##
==========================================
- Coverage   99.55%   99.55%   -0.01%     
==========================================
  Files          64       64              
  Lines        4284     4282       -2     
==========================================
- Hits         4265     4263       -2     
  Misses         19       19              

☔ 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.

Comment thread bellows/uart.py Outdated
@puddly
puddly merged commit 9bcba45 into dev Sep 28, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants