Update the patched UART component to ESPHome 2026.11.0

ESPHome 2026.11's tuya component calls uart.new_uart_component(), which the
2026.10.2 copy didn't have, so the build failed. Copy the UART component from
2026.11.0, reapply the PA13/PA14 patch, regenerate the patch file and point
the refs at v1.0.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-19 00:31:45 +01:00
1 parent bcc6b3a42b
commit 1457e25d98
39 files changed
+907 -304

No files matched your search

+35 -10
View File
@@ -9,11 +9,11 @@
#error This HostUartComponent implementation is not supported on this host OS
#endif
#include <stdio.h>
#include <string.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
@@ -98,7 +98,7 @@ speed_t get_baud(int baud) {
namespace esphome::uart {
static const char *const TAG = "uart";
ESPHOME_LOG_TAG(TAG, "uart");
HostUartComponent::~HostUartComponent() {
if (this->file_descriptor_ != -1) {
@@ -162,11 +162,7 @@ void HostUartComponent::setup() {
break;
};
// Set stop bits
if (this->stop_bits_ == 2) {
options.c_cflag |= CSTOPB;
} else {
options.c_cflag &= ~CSTOPB;
}
assign_bits(options.c_cflag, CSTOPB, this->stop_bits_ == 2);
cfsetispeed(&options, baud);
cfsetospeed(&options, baud);
tcsetattr(this->file_descriptor_, TCSANOW, &options);
@@ -210,7 +206,6 @@ void HostUartComponent::write_array(const uint8_t *data, size_t len) {
this->debug_callback_.call(UART_DIRECTION_TX, data[i]);
}
#endif
return;
}
bool HostUartComponent::peek_byte(uint8_t *data) {
@@ -286,6 +281,36 @@ UARTFlushResult HostUartComponent::flush() {
return UARTFlushResult::UART_FLUSH_RESULT_SUCCESS;
}
bool HostUartComponent::set_modem_control(bool dtr, bool rts) {
if (this->file_descriptor_ == -1) {
return false;
}
// One TIOCMSET so the device never sees a state in between the old and the new one
int bits;
if (ioctl(this->file_descriptor_, TIOCMGET, &bits) == -1) {
this->update_error_(strerror(errno));
return false;
}
bits = (bits & ~(TIOCM_DTR | TIOCM_RTS)) | (dtr ? TIOCM_DTR : 0) | (rts ? TIOCM_RTS : 0);
if (ioctl(this->file_descriptor_, TIOCMSET, &bits) == -1) {
this->update_error_(strerror(errno));
return false;
}
return true;
}
bool HostUartComponent::get_dtr() const { return (this->get_modem_bits_() & TIOCM_DTR) != 0; }
bool HostUartComponent::get_rts() const { return (this->get_modem_bits_() & TIOCM_RTS) != 0; }
int HostUartComponent::get_modem_bits_() const {
int bits = 0;
if (this->file_descriptor_ != -1) {
ioctl(this->file_descriptor_, TIOCMGET, &bits);
}
return bits;
}
void HostUartComponent::update_error_(const std::string &error) {
if (this->first_error_.empty()) {
this->first_error_ = error;