Serial: Only use workaround if we're using serialEvent

This commit is contained in:
gohai
2013-12-15 15:55:31 -08:00
parent 59761b42d2
commit 1c95fd341e

View File

@@ -461,7 +461,10 @@ public class Serial implements SerialPortEventListener {
long start = System.nanoTime();
// this method can be called from the context of another thread
synchronized (buffer) {
toRead = 1;
// read one byte at a time if the sketch is using serialEvent
if (serialEventMethod != null) {
toRead = 1;
}
long len = System.nanoTime()-start;
if (maxReadSyncTime < len) {
maxReadSyncTime = len;