Skip to content

feat(HardwareSerial): Add function to invert Hardware UART's Tx line #11421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

asund
Copy link

@asund asund commented Jun 3, 2025

Description of Change

Simply clone existing HardwareSerial Rx pin inverting functionality for the Tx pin. The goal here is to allow granular control over both lines but avoid overloading HardwareSerial::begin() to change the boolean 'invert' parameter to a bitmask type (though this would be more featureful, I don't want to break the API).

Tests scenarios

I have tested my Pull Request on Arduino-esp32 core v3.2.0 and on ESP32-S2 hardware. I also updated the HardwareSerial test sketch although that functionality just verifies there's no crash, copying existing test for Rx line.

Related links

N/A

…alongside existing Rx functionality

Simply clone existing Rx functionality for Tx. The goal here is to allow granular control over both lines but avoid overloading HardwareSerial::begin() to change the boolean 'invert' parameter to a bitmask type.
@CLAassistant
Copy link

CLAassistant commented Jun 3, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Jun 3, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "feat(HardwareSerial): Add function to invert Hardware UART's Tx line alongside existing Rx functionality":
    • body's lines must not be longer than 100 characters
    • summary appears to be too long
    • scope/component should be lowercase without whitespace, allowed special characters are _ / . , * - .

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 Hello asund, 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 ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against f3ac90d

@lucasssvaz lucasssvaz added the Area: Libraries Issue is related to Library support. label Jun 3, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality for inverting the HardwareSerial TX line, mirroring the existing RX inversion capability without altering the API.

  • Added test cases in uart.ino to verify TX inversion during both running and stopped UART states.
  • Declared and implemented uartSetTxInvert in the ESP32 HAL files with platform-specific behavior.
  • Extended the HardwareSerial API to expose the new setTxInvert method.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/validation/uart/uart.ino Added test calls for TX inversion verification under two scenarios.
cores/esp32/esp32-hal-uart.h Declared the new uartSetTxInvert function.
cores/esp32/esp32-hal-uart.c Implemented uartSetTxInvert with platform-dependent handling.
cores/esp32/HardwareSerial.h Updated the HardwareSerial class interface with setTxInvert.
cores/esp32/HardwareSerial.cpp Implemented setTxInvert by delegating to uartSetTxInvert.

// ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_TXD_INV));
// else
// ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE));
log_e("uartSetTxInvert is not supported in ESP32C6, ESP32H2 and ESP32P4");
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the function's documentation and header comments to clearly state that TX inversion is not supported on ESP32C6, ESP32H2, and ESP32P4, so that users are aware of this platform limitation.

Copilot uses AI. Check for mistakes.

return;
}
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
// POTENTIAL ISSUE :: original code only set/reset txd_inv bit
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider removing or clarifying the commented-out code block if it is no longer needed, to maintain clarity and reduce potential confusion for future maintainers.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Jun 3, 2025

Test Results

 76 files   76 suites   12m 45s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit f3ac90d.

@asund asund closed this Jun 4, 2025
@asund asund deleted the uart_tx_invert branch June 4, 2025 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Libraries Issue is related to Library support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants