ESPHome  2024.10.2
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::uart::UARTComponent Class Referenceabstract

#include <uart_component.h>

Inheritance diagram for esphome::uart::UARTComponent:
esphome::uart::ESP32ArduinoUARTComponent esphome::uart::ESP8266UartComponent esphome::uart::HostUartComponent esphome::uart::IDFUARTComponent esphome::uart::LibreTinyUARTComponent esphome::uart::RP2040UartComponent 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_rx_buffer_size (size_t rx_buffer_size)
 
size_t get_rx_buffer_size ()
 
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. More...
 
virtual void load_settings ()
 Load the UART settings. More...
 
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_
 
size_t rx_buffer_size_
 
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 32 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 153 of file uart_component.h.

◆ available()

virtual int esphome::uart::UARTComponent::available ( )
pure virtual

◆ check_logger_conflict()

virtual void esphome::uart::UARTComponent::check_logger_conflict ( )
protectedpure virtual

◆ 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()

virtual void esphome::uart::UARTComponent::flush ( )
pure virtual

◆ get_baud_rate()

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

Definition at line 123 of file uart_component.h.

◆ get_data_bits()

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

Definition at line 107 of file uart_component.h.

◆ get_parity()

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

Definition at line 115 of file uart_component.h.

◆ get_rx_buffer_size()

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

Definition at line 91 of file uart_component.h.

◆ get_stop_bits()

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

Definition at line 99 of file uart_component.h.

◆ load_settings() [1/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, esphome::uart::ESP32ArduinoUARTComponent, and esphome::uart::IDFUARTComponent.

Definition at line 137 of file uart_component.h.

◆ load_settings() [2/2]

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

Load the UART settings.

Example:

id(uart1).load_settings();

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

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

Definition at line 149 of file uart_component.h.

◆ peek_byte()

virtual bool esphome::uart::UARTComponent::peek_byte ( uint8_t *  data)
pure virtual

◆ read_array()

virtual bool esphome::uart::UARTComponent::read_array ( uint8_t *  data,
size_t  len 
)
pure virtual

◆ read_byte()

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

Definition at line 57 of file uart_component.h.

◆ set_baud_rate()

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

Definition at line 119 of file uart_component.h.

◆ set_data_bits()

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

Definition at line 103 of file uart_component.h.

◆ set_parity()

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

Definition at line 111 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 87 of file uart_component.h.

◆ set_rx_pin()

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

Definition at line 83 of file uart_component.h.

◆ set_stop_bits()

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

Definition at line 95 of file uart_component.h.

◆ set_tx_pin()

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

Definition at line 79 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 36 of file uart_component.h.

◆ write_array() [2/2]

virtual void esphome::uart::UARTComponent::write_array ( const uint8_t *  data,
size_t  len 
)
pure virtual

◆ write_byte()

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

Definition at line 40 of file uart_component.h.

◆ write_str()

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

Definition at line 44 of file uart_component.h.

Field Documentation

◆ baud_rate_

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

Definition at line 165 of file uart_component.h.

◆ data_bits_

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

Definition at line 167 of file uart_component.h.

◆ debug_callback_

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

Definition at line 170 of file uart_component.h.

◆ parity_

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

Definition at line 168 of file uart_component.h.

◆ rx_buffer_size_

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

Definition at line 164 of file uart_component.h.

◆ rx_pin_

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

Definition at line 163 of file uart_component.h.

◆ stop_bits_

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

Definition at line 166 of file uart_component.h.

◆ tx_pin_

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

Definition at line 162 of file uart_component.h.


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