aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-07-31 16:48:15 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-07-31 16:49:00 -0400
commitd0fc50d44d664329f6336b4bef9c9e62a12768be (patch)
treecb9e088e3e4639febeb8d4af7378a1c87b95840a /wirish
parentc8b7f0b5b390ff4cae32566d53f4410e72de4573 (diff)
downloadlibrambutan-d0fc50d44d664329f6336b4bef9c9e62a12768be.tar.gz
librambutan-d0fc50d44d664329f6336b4bef9c9e62a12768be.zip
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')
-rw-r--r--wirish/HardwareSerial.cpp3
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);
}