summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Teichman <peter@teichman.org>2011-12-04 13:43:24 -0500
committerPeter Teichman <peter@teichman.org>2011-12-04 17:18:27 -0500
commit4eefaaaeff30fd2a9dcea6627364dfc52d8ac76f (patch)
treeeb4f689bb59112a2d2fd4b9350c4a5c7d25ec706
parent1c0d64f96e5d2bbdecf053e258459fe2f101ac22 (diff)
Check serial.available() before trying to readHEADmaster
The Maple API returns an unsigned char from read(), making the old check for -1 incorrect.
-rw-r--r--Midi.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/Midi.cpp b/Midi.cpp
index 2b95eed..b5655de 100644
--- a/Midi.cpp
+++ b/Midi.cpp
@@ -225,13 +225,10 @@ void Midi::recvByte(int byte)
// Try to read data at serial port & pass anything read to processing function
void Midi::poll(void)
{
- int c;
-
-
// Just keep sucking data from serial port until it runs out, processing
// MIDI messages as we go
- while((c = serial_.read()) != -1) {
- recvByte(c);
+ while(serial_.available() > 0) {
+ recvByte(serial_.read());
}
}