Only process data_received events if >0 bytes were read
This commit is contained in:
parent
23f29278c2
commit
daa26dd8ad
|
@ -2,7 +2,7 @@
|
||||||
* SerialPort.java
|
* SerialPort.java
|
||||||
*
|
*
|
||||||
* Created on: Feb 25, 2012
|
* Created on: Feb 25, 2012
|
||||||
* Last Updated on: Jan 27, 2022
|
* Last Updated on: Jan 28, 2022
|
||||||
* Author: Will Hedgecock
|
* Author: Will Hedgecock
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2022 Fazecast, Inc.
|
* Copyright (C) 2012-2022 Fazecast, Inc.
|
||||||
|
@ -1759,6 +1759,8 @@ public final class SerialPort
|
||||||
newBytesIndex = 0;
|
newBytesIndex = 0;
|
||||||
byte[] newBytes = new byte[numBytesAvailable];
|
byte[] newBytes = new byte[numBytesAvailable];
|
||||||
bytesRemaining = readBytes(portHandle, newBytes, newBytes.length, 0, timeoutMode, readTimeout);
|
bytesRemaining = readBytes(portHandle, newBytes, newBytes.length, 0, timeoutMode, readTimeout);
|
||||||
|
if (bytesRemaining > 0)
|
||||||
|
{
|
||||||
if (delimiters.length > 0)
|
if (delimiters.length > 0)
|
||||||
{
|
{
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
|
@ -1802,6 +1804,7 @@ public final class SerialPort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (event != LISTENING_EVENT_TIMED_OUT)
|
if (event != LISTENING_EVENT_TIMED_OUT)
|
||||||
userDataListener.serialEvent(new SerialPortEvent(SerialPort.this, event));
|
userDataListener.serialEvent(new SerialPortEvent(SerialPort.this, event));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue