pw_sys_io_arduino: Fix broken while loop in WriteByte
This was causing hangs. Removed since Serial.write will
block under the hood as is.
Change-Id: I4ce5caedbd0f9e371e1c0c916c4ee963f838a6aa
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31973
Reviewed-by: Stan Iliev <stani@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_sys_io_arduino/sys_io_arduino.cc b/pw_sys_io_arduino/sys_io_arduino.cc
index 9e86c73..4709ad5 100644
--- a/pw_sys_io_arduino/sys_io_arduino.cc
+++ b/pw_sys_io_arduino/sys_io_arduino.cc
@@ -44,15 +44,9 @@
return OkStatus();
}
-// Send a byte over USART1. Since this blocks on every byte, it's rather
-// inefficient. At the default baud rate of 115200, one byte blocks the CPU for
-// ~87 micro seconds. This means it takes only 10 bytes to block the CPU for
-// 1ms!
+// Send a byte over the default Arduino Serial port.
Status WriteByte(std::byte b) {
- // Wait for TX buffer to be empty. When the buffer is empty, we can write
- // a value to be dumped out of UART.
- while (Serial.availableForWrite() < 1) {
- }
+ // Serial.write() will block until data can be written.
Serial.write((uint8_t)b);
return OkStatus();
}