Ensure we can break out of while loop waiting for full message retrieval

This commit is contained in:
hedgecrw85 2019-04-15 10:54:22 -05:00
parent 69aba390fa
commit 7fdab3aea6
1 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@
* SerialPort.java
*
* Created on: Feb 25, 2012
* Last Updated on: Mar 22, 2019
* Last Updated on: Apr 15, 2019
* Author: Will Hedgecock
*
* Copyright (C) 2012-2019 Fazecast, Inc.
@ -1198,7 +1198,7 @@ public final class SerialPort
{
// Read data from serial port
int numBytesAvailable, bytesRemaining, newBytesIndex;
while ((numBytesAvailable = bytesAvailable(portHandle)) > 0)
while (isListening && ((numBytesAvailable = bytesAvailable(portHandle)) > 0))
{
byte[] newBytes = new byte[numBytesAvailable];
newBytesIndex = 0;