25 lines
519 B
C++
25 lines
519 B
C++
#include "uart_component.h"
|
|
|
|
namespace esphome {
|
|
namespace uart {
|
|
|
|
static const char *const TAG = "uart";
|
|
|
|
bool UARTComponent::check_read_timeout_(size_t len) {
|
|
if (this->available() >= int(len))
|
|
return true;
|
|
|
|
uint32_t start_time = millis();
|
|
while (this->available() < int(len)) {
|
|
if (millis() - start_time > 100) {
|
|
ESP_LOGE(TAG, "Reading from UART timed out at byte %u!", this->available());
|
|
return false;
|
|
}
|
|
yield();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace uart
|
|
} // namespace esphome
|