diff options
| author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-07-31 16:48:15 -0400 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-07-31 16:49:00 -0400 |
| commit | 15b8a03de97078823ed431e472aedb0988d62220 (patch) | |
| tree | cb9e088e3e4639febeb8d4af7378a1c87b95840a /wirish/HardwareSerial.cpp | |
| parent | 365f45679b99a6bcb1da7eb7eaa62738332515f4 (diff) | |
HardwareSerial: make read() block until data arrive.
This makes the HardwareSerial behavior match that of SerialUSB, and
should help avoid confusion.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish/HardwareSerial.cpp')
| -rw-r--r-- | wirish/HardwareSerial.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index e78156d..3036983 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -118,6 +118,9 @@ void HardwareSerial::end(void) { */ uint8 HardwareSerial::read(void) { + // Block until a byte becomes available, to save user confusion. + while (!this->available()) + ; return usart_getc(this->usart_device); } |
