fix(uart): fixes setPins() when changing RTS and CTS#12201
fix(uart): fixes setPins() when changing RTS and CTS#12201
Conversation
👋 Hello SuGlider, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 90 files 90 suites 28m 25s ⏱️ Results for commit bef7ed0. ♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue with HardwareSerial::setPins() when changing RTS and CTS pins before calling begin(). The fix leverages improvements in ESP-IDF 5.1+ that have been backported from 5.5.2 to 5.1.0, which now properly support changing individual UART pins. The PR also adds a comprehensive hardware flow control example and documentation for testing functions.
Key changes:
- Replaces internal
_uartInternalSetPin()implementation with IDF'suart_set_pin()to properly handle RTS/CTS pin configuration - Adds new
uart_internal_hw_flow_ctrl_loopback()helper function for testing hardware flow control without external wires - Provides a complete HardwareFlowControl_Demo example demonstrating both hardware-controlled and GPIO-controlled flow control modes
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cores/esp32/esp32-hal-uart.c | Removes custom _uartInternalSetPin() implementation and replaces calls with IDF's uart_set_pin(); adds uart_internal_hw_flow_ctrl_loopback() function for testing; fixes spelling errors in comments |
| cores/esp32/esp32-hal-uart.h | Adds declaration for uart_internal_hw_flow_ctrl_loopback() function; fixes spelling error in comment |
| libraries/ESP32/examples/Serial/HardwareFlowControl_Demo/HardwareFlowControl_Demo.ino | New comprehensive example demonstrating UART hardware flow control with RTS/CTS signals, supporting both internal GPIO matrix loopback and external wire connections |
| libraries/ESP32/examples/Serial/HardwareFlowControl_Demo/README.md | New detailed documentation explaining hardware flow control concepts, pin connections, configuration options, and expected behavior for both hardware-controlled and GPIO-controlled modes |
| docs/en/api/serial.rst | Adds documentation for uart_internal_loopback() and uart_internal_hw_flow_ctrl_loopback() testing functions with usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
libraries/ESP32/examples/Serial/HardwareFlowControl_Demo/README.md
Outdated
Show resolved
Hide resolved
libraries/ESP32/examples/Serial/HardwareFlowControl_Demo/README.md
Outdated
Show resolved
Hide resolved
libraries/ESP32/examples/Serial/HardwareFlowControl_Demo/README.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Updated README.md to include additional pin connection details and modified function descriptions for hardware flow control.
|
Can we add a test case in our UART testing for this ? |
Sure! Do you want to do that or you expect me to add it? |
|
@SuGlider If you can add it in this PR would be good so we can check that everything passes in the test. |
…m/espressif/arduino-esp32 into fix/uart_set_pins_rts_cts_failure
CI HW flow control test case added. |
|
@lucasssvaz | @me-no-dev : PR is completed. Please review it. |
|
@SuGlider Tests are failing. PTAL |
Thre is nothing that I do for it. It works fine with real SoC. ESP32 Log:ESP32-S3 Log: |
|
Wokwi is fixed and CI is passing again. |
|
|
@P-R-O-C-H-Y - It is failing Baudrate Detection with the ESP32-S2. Wokwi CI Failure (baudrate test): This is the Real SoC output: |
|
Please wait for #12215 so Wokwi CI can be re-triggered for all Socs. |
|
PR is good to go! |
Description of Change
IDF 5.1+ has finally fixed the issue related to changing a single UART pin (rx, tx, cts, rts).
It has been backported from 5.5.2 to 5.1.0.
An issue was found that prevents RTS and CTS pins to be correctly configures when
HardwareSerial::setPins()is executed beforeHardwareSerial::begin(). This issue is fixed by the change from IDF in conjuction with the changes of this PR.As part of the testing and also for demonstation purpose, a new RX-TX + RTS-CTS loopback using Hardware Flow Control has been provided as part of this PR.
Test Scenarios
tested using an ESP32-S3 and the provided examples in different configurations.
Related links
Closes #12199