add uart number to LOGCONFIG (#3996)

This commit is contained in:
tomaszduda23 2022-11-07 00:58:56 +01:00 committed by GitHub
parent de79171815
commit 90683223dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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) {

View File

@ -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