[uart] Return flush result, expose timeout via config (#14608)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
Keith Burzinski
2026-03-08 05:23:13 +00:00
committed by GitHub
co-authored by J. Nick Koston pre-commit-ci-lite[bot]
parent be6c3c52ac
commit 5e842a8b20
25 changed files with 77 additions and 30 deletions
+4 -1
View File
@@ -166,7 +166,7 @@ void USBUartChannel::write_array(const uint8_t *data, size_t len) {
this->parent_->start_output(this);
}
void USBUartChannel::flush() {
uart::FlushResult USBUartChannel::flush() {
// Spin until the output queue is drained and the last USB transfer completes.
// Safe to call from the main loop only.
// The 100 ms timeout guards against a device that stops responding mid-flush;
@@ -177,6 +177,9 @@ void USBUartChannel::flush() {
this->parent_->start_output(this);
yield();
}
if (!this->output_queue_.empty() || this->output_started_.load())
return uart::FlushResult::TIMEOUT;
return uart::FlushResult::SUCCESS;
}
bool USBUartChannel::peek_byte(uint8_t *data) {