ESPHome  2024.11.3
uart_component_host.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_HOST
4 
6 #include "esphome/core/log.h"
7 #include "uart_component.h"
8 
9 namespace esphome {
10 namespace uart {
11 
12 class HostUartComponent : public UARTComponent, public Component {
13  public:
14  virtual ~HostUartComponent();
15  void setup() override;
16  void dump_config() override;
17  float get_setup_priority() const override { return setup_priority::BUS; }
18  void write_array(const uint8_t *data, size_t len) override;
19  bool peek_byte(uint8_t *data) override;
20  bool read_array(uint8_t *data, size_t len) override;
21  int available() override;
22  void flush() override;
23  void set_name(std::string port_name) { port_name_ = port_name; };
24 
25  protected:
26  void update_error_(const std::string &error);
27  void check_logger_conflict() override {}
28  std::string port_name_;
29  std::string first_error_{""};
30  int file_descriptor_ = -1;
31  bool has_peek_{false};
32  uint8_t peek_byte_;
33 };
34 
35 } // namespace uart
36 } // namespace esphome
37 
38 #endif // USE_HOST
float get_setup_priority() const override
const float BUS
For communication buses like i2c/spi.
Definition: component.cpp:16
void set_name(std::string port_name)
void write_array(const uint8_t *data, size_t len) override
void update_error_(const std::string &error)
std::string size_t len
Definition: helpers.h:293
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool read_array(uint8_t *data, size_t len) override
bool peek_byte(uint8_t *data) override