Skip to content

Commit e85aec5

Browse files
committed
Serial: Only use workaround if we're using serialEvent
1 parent 9541cbb commit e85aec5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

java/libraries/serial/src/processing/serial/Serial.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ public void serialEvent(SerialPortEvent event) {
461461
long start = System.nanoTime();
462462
// this method can be called from the context of another thread
463463
synchronized (buffer) {
464-
toRead = 1;
464+
// read one byte at a time if the sketch is using serialEvent
465+
if (serialEventMethod != null) {
466+
toRead = 1;
467+
}
465468
long len = System.nanoTime()-start;
466469
if (maxReadSyncTime < len) {
467470
maxReadSyncTime = len;

0 commit comments

Comments
 (0)