diff --git a/esphome/components/uart/uart_component_host.cpp b/esphome/components/uart/uart_component_host.cpp index 085610a983..5bb7a49726 100644 --- a/esphome/components/uart/uart_component_host.cpp +++ b/esphome/components/uart/uart_component_host.cpp @@ -276,9 +276,12 @@ UARTFlushResult HostUartComponent::flush() { if (this->file_descriptor_ == -1) { return UARTFlushResult::UART_FLUSH_RESULT_ASSUMED_SUCCESS; } - tcflush(this->file_descriptor_, TCIOFLUSH); ESP_LOGV(TAG, " Flushing"); - return UARTFlushResult::UART_FLUSH_RESULT_ASSUMED_SUCCESS; + if (tcdrain(this->file_descriptor_) == -1) { + this->update_error_(strerror(errno)); + return UARTFlushResult::UART_FLUSH_RESULT_FAILED; + } + return UARTFlushResult::UART_FLUSH_RESULT_SUCCESS; } void HostUartComponent::update_error_(const std::string &error) {