ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
uart_component.cpp
Go to the documentation of this file.
1#include "uart_component.h"
2
3namespace esphome::uart {
4
5static const char *const TAG = "uart";
6
8 if (this->available() >= int(len))
9 return true;
10
11 uint32_t start_time = millis();
12 while (this->available() < int(len)) {
13 if (millis() - start_time > 100) {
14 ESP_LOGE(TAG, "Reading from UART timed out at byte %u!", this->available());
15 return false;
16 }
17 yield();
18 }
19 return true;
20}
21
23 uint8_t bytelength = this->data_bits_ + this->stop_bits_ + 1;
25 bytelength += 1;
26 int32_t val = clamp<int32_t>((this->baud_rate_ / (bytelength * 1000 / time)) - 1, 1, 120);
27 this->set_rx_full_threshold(val);
28}
29
30} // namespace esphome::uart
bool check_read_timeout_(size_t len=1)
void set_rx_full_threshold_ms(uint8_t time)
virtual void set_rx_full_threshold(size_t rx_full_threshold)
mopeka_std_values val[4]
const char *const TAG
Definition spi.cpp:7
std::string size_t len
Definition helpers.h:533
void IRAM_ATTR HOT yield()
Definition core.cpp:24
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:25