Only process data_received events if >0 bytes were read

This commit is contained in:
Will Hedgecock 2022-01-28 11:04:10 -06:00
parent 23f29278c2
commit daa26dd8ad
1 changed files with 38 additions and 35 deletions

View File

@ -2,7 +2,7 @@
* SerialPort.java
*
* Created on: Feb 25, 2012
* Last Updated on: Jan 27, 2022
* Last Updated on: Jan 28, 2022
* Author: Will Hedgecock
*
* Copyright (C) 2012-2022 Fazecast, Inc.
@ -1759,6 +1759,8 @@ public final class SerialPort
newBytesIndex = 0;
byte[] newBytes = new byte[numBytesAvailable];
bytesRemaining = readBytes(portHandle, newBytes, newBytes.length, 0, timeoutMode, readTimeout);
if (bytesRemaining > 0)
{
if (delimiters.length > 0)
{
int startIndex = 0;
@ -1802,6 +1804,7 @@ public final class SerialPort
}
}
}
}
if (event != LISTENING_EVENT_TIMED_OUT)
userDataListener.serialEvent(new SerialPortEvent(SerialPort.this, event));
}