mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 13:24:15 +01:00
Warn when UART and logger operating on same bus (#803)
This commit is contained in:
parent
6ae59bb43d
commit
1bf01a9081
@ -30,6 +30,7 @@ class Logger : public Component {
|
||||
|
||||
/// Manually set the baud rate for serial, set to 0 to disable.
|
||||
void set_baud_rate(uint32_t baud_rate);
|
||||
uint32_t get_baud_rate() const { return baud_rate_; }
|
||||
|
||||
/// Get the UART used by the logger.
|
||||
UARTSelection get_uart() const;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user