ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
uart_component_host.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_HOST
4
5#include <utility>
6
8#include "esphome/core/log.h"
9#include "uart_component.h"
10
11namespace esphome::uart {
12
13class HostUartComponent final : public UARTComponent, public Component {
14 public:
16 void setup() override;
17 void dump_config() override;
18 float get_setup_priority() const override { return setup_priority::BUS; }
19 void write_array(const uint8_t *data, size_t len) override;
20 bool peek_byte(uint8_t *data) override;
21 bool read_array(uint8_t *data, size_t len) override;
22 size_t available() override;
23 UARTFlushResult flush() override;
25 bool set_modem_control(bool dtr, bool rts);
26 bool get_dtr() const;
27 bool get_rts() const;
28 void set_name(std::string port_name) { this->port_name_ = std::move(port_name); }
29
30 protected:
31 void update_error_(const std::string &error);
32 int get_modem_bits_() const;
33 void check_logger_conflict() override {}
34 std::string port_name_;
35 std::string first_error_;
37 bool has_peek_{false};
38 uint8_t peek_byte_;
39};
40
41} // namespace esphome::uart
42#endif // USE_HOST
bool read_array(uint8_t *data, size_t len) override
bool set_modem_control(bool dtr, bool rts)
Drive DTR/RTS. Returns false when the port is closed or the ioctl fails.
float get_setup_priority() const override
void write_array(const uint8_t *data, size_t len) override
void update_error_(const std::string &error)
void set_name(std::string port_name)
bool peek_byte(uint8_t *data) override
constexpr float BUS
For communication buses like i2c/spi.
Definition component.h:39
UARTFlushResult
Result of a flush() call.
const void size_t len
Definition hal.h:68