ESPHome 2025.10.0-dev
Loading...
Searching...
No Matches
uart_component.cpp
Go to the documentation of this file.
1#include "uart_component.h"
2
3namespace esphome {
4namespace uart {
5
6static const char *const TAG = "uart";
7
9 if (this->available() >= int(len))
10 return true;
11
12 uint32_t start_time = millis();
13 while (this->available() < int(len)) {
14 if (millis() - start_time > 100) {
15 ESP_LOGE(TAG, "Reading from UART timed out at byte %u!", this->available());
16 return false;
17 }
18 yield();
19 }
20 return true;
21}
22
24 uint8_t bytelength = this->data_bits_ + this->stop_bits_ + 1;
26 bytelength += 1;
27 int32_t val = clamp<int32_t>((this->baud_rate_ / (bytelength * 1000 / time)) - 1, 1, 120);
28 this->set_rx_full_threshold(val);
29}
30
31} // namespace uart
32} // namespace esphome
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:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:291
void IRAM_ATTR HOT yield()
Definition core.cpp:27
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:28