ESPHome 2025.10.0-dev
Loading...
Searching...
No Matches
esphome::uart::UARTComponent Class Referenceabstract

#include <uart_component.h>

Inheritance diagram for esphome::uart::UARTComponent:
esphome::uart::ESP8266UartComponent esphome::uart::HostUartComponent esphome::uart::IDFUARTComponent esphome::uart::LibreTinyUARTComponent esphome::uart::RP2040UartComponent esphome::usb_uart::USBUartChannel esphome::weikai::WeikaiChannel

Public Member Functions

void write_array (const std::vector< uint8_t > &data)
 
void write_byte (uint8_t data)
 
void write_str (const char *str)
 
virtual void write_array (const uint8_t *data, size_t len)=0
 
bool read_byte (uint8_t *data)
 
virtual bool peek_byte (uint8_t *data)=0
 
virtual bool read_array (uint8_t *data, size_t len)=0
 
virtual int available ()=0
 
virtual void flush ()=0
 
void set_tx_pin (InternalGPIOPin *tx_pin)
 
void set_rx_pin (InternalGPIOPin *rx_pin)
 
void set_flow_control_pin (InternalGPIOPin *flow_control_pin)
 
void set_rx_buffer_size (size_t rx_buffer_size)
 
size_t get_rx_buffer_size ()
 
virtual void set_rx_full_threshold (size_t rx_full_threshold)
 
void set_rx_full_threshold_ms (uint8_t time)
 
size_t get_rx_full_threshold ()
 
virtual void set_rx_timeout (size_t rx_timeout)
 
size_t get_rx_timeout ()
 
void set_stop_bits (uint8_t stop_bits)
 
uint8_t get_stop_bits () const
 
void set_data_bits (uint8_t data_bits)
 
uint8_t get_data_bits () const
 
void set_parity (UARTParityOptions parity)
 
UARTParityOptions get_parity () const
 
void set_baud_rate (uint32_t baud_rate)
 
uint32_t get_baud_rate () const
 
virtual void load_settings (bool dump_config)
 Load the UART settings.
 
virtual void load_settings ()
 Load the UART settings.
 
void add_debug_callback (std::function< void(UARTDirection, uint8_t)> &&callback)
 

Protected Member Functions

virtual void check_logger_conflict ()=0
 
bool check_read_timeout_ (size_t len=1)
 

Protected Attributes

InternalGPIOPintx_pin_
 
InternalGPIOPinrx_pin_
 
InternalGPIOPinflow_control_pin_
 
size_t rx_buffer_size_
 
size_t rx_full_threshold_ {1}
 
size_t rx_timeout_ {0}
 
uint32_t baud_rate_
 
uint8_t stop_bits_
 
uint8_t data_bits_
 
UARTParityOptions parity_
 
CallbackManager< void(UARTDirection, uint8_t)> debug_callback_ {}
 

Detailed Description

Definition at line 33 of file uart_component.h.

Member Function Documentation

◆ add_debug_callback()

void esphome::uart::UARTComponent::add_debug_callback ( std::function< void(UARTDirection, uint8_t)> && callback)
inline

Definition at line 178 of file uart_component.h.

◆ available()

◆ check_logger_conflict()

◆ check_read_timeout_()

bool esphome::uart::UARTComponent::check_read_timeout_ ( size_t len = 1)
protected

Definition at line 8 of file uart_component.cpp.

◆ flush()

◆ get_baud_rate()

uint32_t esphome::uart::UARTComponent::get_baud_rate ( ) const
inline

Definition at line 148 of file uart_component.h.

◆ get_data_bits()

uint8_t esphome::uart::UARTComponent::get_data_bits ( ) const
inline

Definition at line 132 of file uart_component.h.

◆ get_parity()

UARTParityOptions esphome::uart::UARTComponent::get_parity ( ) const
inline

Definition at line 140 of file uart_component.h.

◆ get_rx_buffer_size()

size_t esphome::uart::UARTComponent::get_rx_buffer_size ( )
inline

Definition at line 96 of file uart_component.h.

◆ get_rx_full_threshold()

size_t esphome::uart::UARTComponent::get_rx_full_threshold ( )
inline

Definition at line 108 of file uart_component.h.

◆ get_rx_timeout()

size_t esphome::uart::UARTComponent::get_rx_timeout ( )
inline

Definition at line 116 of file uart_component.h.

◆ get_stop_bits()

uint8_t esphome::uart::UARTComponent::get_stop_bits ( ) const
inline

Definition at line 124 of file uart_component.h.

◆ load_settings() [1/2]

virtual void esphome::uart::UARTComponent::load_settings ( )
inlinevirtual

Load the UART settings.

Example:

id(uart1).load_settings();
uint16_t id

This will load the current UART interface with the latest settings (baud_rate, parity, etc).

Reimplemented in esphome::uart::ESP8266UartComponent, and esphome::uart::IDFUARTComponent.

Definition at line 174 of file uart_component.h.

◆ load_settings() [2/2]

virtual void esphome::uart::UARTComponent::load_settings ( bool dump_config)
inlinevirtual

Load the UART settings.

Parameters
dump_configIf true (default), output the new settings to logs; otherwise, change settings quietly.

Example:

id(uart1).load_settings(false);

This will load the current UART interface with the latest settings (baud_rate, parity, etc).

Reimplemented in esphome::uart::ESP8266UartComponent, and esphome::uart::IDFUARTComponent.

Definition at line 162 of file uart_component.h.

◆ peek_byte()

◆ read_array()

◆ read_byte()

bool esphome::uart::UARTComponent::read_byte ( uint8_t * data)
inline

Definition at line 58 of file uart_component.h.

◆ set_baud_rate()

void esphome::uart::UARTComponent::set_baud_rate ( uint32_t baud_rate)
inline

Definition at line 144 of file uart_component.h.

◆ set_data_bits()

void esphome::uart::UARTComponent::set_data_bits ( uint8_t data_bits)
inline

Definition at line 128 of file uart_component.h.

◆ set_flow_control_pin()

void esphome::uart::UARTComponent::set_flow_control_pin ( InternalGPIOPin * flow_control_pin)
inline

Definition at line 88 of file uart_component.h.

◆ set_parity()

void esphome::uart::UARTComponent::set_parity ( UARTParityOptions parity)
inline

Definition at line 136 of file uart_component.h.

◆ set_rx_buffer_size()

void esphome::uart::UARTComponent::set_rx_buffer_size ( size_t rx_buffer_size)
inline

Definition at line 92 of file uart_component.h.

◆ set_rx_full_threshold()

virtual void esphome::uart::UARTComponent::set_rx_full_threshold ( size_t rx_full_threshold)
inlinevirtual

Reimplemented in esphome::uart::IDFUARTComponent.

Definition at line 100 of file uart_component.h.

◆ set_rx_full_threshold_ms()

void esphome::uart::UARTComponent::set_rx_full_threshold_ms ( uint8_t time)

Definition at line 23 of file uart_component.cpp.

◆ set_rx_pin()

void esphome::uart::UARTComponent::set_rx_pin ( InternalGPIOPin * rx_pin)
inline

Definition at line 84 of file uart_component.h.

◆ set_rx_timeout()

virtual void esphome::uart::UARTComponent::set_rx_timeout ( size_t rx_timeout)
inlinevirtual

Reimplemented in esphome::uart::IDFUARTComponent.

Definition at line 112 of file uart_component.h.

◆ set_stop_bits()

void esphome::uart::UARTComponent::set_stop_bits ( uint8_t stop_bits)
inline

Definition at line 120 of file uart_component.h.

◆ set_tx_pin()

void esphome::uart::UARTComponent::set_tx_pin ( InternalGPIOPin * tx_pin)
inline

Definition at line 80 of file uart_component.h.

◆ write_array() [1/2]

void esphome::uart::UARTComponent::write_array ( const std::vector< uint8_t > & data)
inline

Definition at line 37 of file uart_component.h.

◆ write_array() [2/2]

◆ write_byte()

void esphome::uart::UARTComponent::write_byte ( uint8_t data)
inline

Definition at line 41 of file uart_component.h.

◆ write_str()

void esphome::uart::UARTComponent::write_str ( const char * str)
inline

Definition at line 45 of file uart_component.h.

Field Documentation

◆ baud_rate_

uint32_t esphome::uart::UARTComponent::baud_rate_
protected

Definition at line 193 of file uart_component.h.

◆ data_bits_

uint8_t esphome::uart::UARTComponent::data_bits_
protected

Definition at line 195 of file uart_component.h.

◆ debug_callback_

CallbackManager<void(UARTDirection, uint8_t)> esphome::uart::UARTComponent::debug_callback_ {}
protected

Definition at line 198 of file uart_component.h.

◆ flow_control_pin_

InternalGPIOPin* esphome::uart::UARTComponent::flow_control_pin_
protected

Definition at line 189 of file uart_component.h.

◆ parity_

UARTParityOptions esphome::uart::UARTComponent::parity_
protected

Definition at line 196 of file uart_component.h.

◆ rx_buffer_size_

size_t esphome::uart::UARTComponent::rx_buffer_size_
protected

Definition at line 190 of file uart_component.h.

◆ rx_full_threshold_

size_t esphome::uart::UARTComponent::rx_full_threshold_ {1}
protected

Definition at line 191 of file uart_component.h.

◆ rx_pin_

InternalGPIOPin* esphome::uart::UARTComponent::rx_pin_
protected

Definition at line 188 of file uart_component.h.

◆ rx_timeout_

size_t esphome::uart::UARTComponent::rx_timeout_ {0}
protected

Definition at line 192 of file uart_component.h.

◆ stop_bits_

uint8_t esphome::uart::UARTComponent::stop_bits_
protected

Definition at line 194 of file uart_component.h.

◆ tx_pin_

InternalGPIOPin* esphome::uart::UARTComponent::tx_pin_
protected

Definition at line 187 of file uart_component.h.


The documentation for this class was generated from the following files: