1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-28 08:02:23 +01:00

Warn when UART and logger operating on same bus (#803)

This commit is contained in:
Otto Winter
2019-10-27 12:27:46 +01:00
committed by GitHub
parent 5a67e72389
commit c1f5e04d6c
2 changed files with 19 additions and 0 deletions

View File

@@ -2,6 +2,11 @@
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include "esphome/core/application.h"
#include "esphome/core/defines.h"
#ifdef USE_LOGGER
#include "esphome/components/logger/logger.h"
#endif
namespace esphome {
namespace uart {
@@ -41,6 +46,12 @@ void UARTComponent::dump_config() {
}
ESP_LOGCONFIG(TAG, " Baud Rate: %u baud", this->baud_rate_);
ESP_LOGCONFIG(TAG, " Stop bits: %u", this->stop_bits_);
#ifdef USE_LOGGER
if (this->hw_serial_ == &Serial && logger::global_logger->get_baud_rate() != 0) {
ESP_LOGW(TAG, " You're using the same serial port for logging and the UART component. Please "
"disable logging over the serial port by setting logger->baud_rate to 0.");
}
#endif
}
void UARTComponent::write_byte(uint8_t data) {
@@ -145,6 +156,13 @@ void UARTComponent::dump_config() {
} else {
ESP_LOGCONFIG(TAG, " Using software serial");
}
#ifdef USE_LOGGER
if (this->hw_serial_ == &Serial && logger::global_logger->get_baud_rate() != 0) {
ESP_LOGW(TAG, " You're using the same serial port for logging and the UART component. Please "
"disable logging over the serial port by setting logger->baud_rate to 0.");
}
#endif
}
void UARTComponent::write_byte(uint8_t data) {