ESPHome  2022.9.1
uart_component.cpp
Go to the documentation of this file.
1 #include "uart_component.h"
2 
3 namespace esphome {
4 namespace uart {
5 
6 static 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 
23 } // namespace uart
24 } // namespace esphome
uint32_t IRAM_ATTR HOT millis()
Definition: core.cpp:26
virtual int available()=0
Return available number of bytes.
std::string size_t len
Definition: helpers.h:281
void IRAM_ATTR HOT yield()
Definition: core.cpp:25
Definition: a4988.cpp:4
bool check_read_timeout_(size_t len=1)