From 0d974b70ef611bf328c379191d1b78dcb090797f Mon Sep 17 00:00:00 2001 From: TehDmitry Date: Fri, 22 Sep 2017 13:50:46 +0300 Subject: [PATCH] Do not pass empty frameBytes --- CANtactCore/src/org/cantact/core/CantactDevice.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CANtactCore/src/org/cantact/core/CantactDevice.java b/CANtactCore/src/org/cantact/core/CantactDevice.java index dbd0436..581c9ae 100644 --- a/CANtactCore/src/org/cantact/core/CantactDevice.java +++ b/CANtactCore/src/org/cantact/core/CantactDevice.java @@ -174,9 +174,11 @@ public void serialEvent(SerialPortEvent event) { for (byte b : bs) { if (b == '\r') { - // end of frame data received - CanFrame f = slcanToFrame(frameBytes.toArray(new Byte[frameBytes.size()])); - DeviceManager.giveFrame(f); + if(frameBytes.size() > 4) { + // end of frame data received + CanFrame f = slcanToFrame(frameBytes.toArray(new Byte[frameBytes.size()])); + DeviceManager.giveFrame(f); + } frameBytes.clear(); } else { // byte received, add to buffer