From 90683223dd8d351397485e58cbb2a3a23f359193 Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Mon, 7 Nov 2022 00:58:56 +0100 Subject: [PATCH] add uart number to LOGCONFIG (#3996) --- esphome/components/uart/uart_component_esp32_arduino.cpp | 3 ++- esphome/components/uart/uart_component_esp32_arduino.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/uart/uart_component_esp32_arduino.cpp b/esphome/components/uart/uart_component_esp32_arduino.cpp index a67e5354fb..402e41e0b5 100644 --- a/esphome/components/uart/uart_component_esp32_arduino.cpp +++ b/esphome/components/uart/uart_component_esp32_arduino.cpp @@ -90,6 +90,7 @@ void ESP32ArduinoUARTComponent::setup() { this->hw_serial_ = &Serial; } else { static uint8_t next_uart_num = 1; + this->number_ = next_uart_num; this->hw_serial_ = new HardwareSerial(next_uart_num++); // NOLINT(cppcoreguidelines-owning-memory) } int8_t tx = this->tx_pin_ != nullptr ? this->tx_pin_->get_pin() : -1; @@ -104,7 +105,7 @@ void ESP32ArduinoUARTComponent::setup() { } void ESP32ArduinoUARTComponent::dump_config() { - ESP_LOGCONFIG(TAG, "UART Bus:"); + ESP_LOGCONFIG(TAG, "UART Bus %d:", this->number_); LOG_PIN(" TX Pin: ", tx_pin_); LOG_PIN(" RX Pin: ", rx_pin_); if (this->rx_pin_ != nullptr) { diff --git a/esphome/components/uart/uart_component_esp32_arduino.h b/esphome/components/uart/uart_component_esp32_arduino.h index c6f445ff12..4a000b12d2 100644 --- a/esphome/components/uart/uart_component_esp32_arduino.h +++ b/esphome/components/uart/uart_component_esp32_arduino.h @@ -32,6 +32,7 @@ class ESP32ArduinoUARTComponent : public UARTComponent, public Component { void check_logger_conflict() override; HardwareSerial *hw_serial_{nullptr}; + uint8_t number_{0}; }; } // namespace uart