From 991663409ab875aa22bb181d4833a490e5db1b50 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 26 Feb 2013 17:42:55 +0100 Subject: [PATCH] null check on SerialPort.readBytes --- app/src/processing/app/Serial.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/Serial.java b/app/src/processing/app/Serial.java index c1caaec4a..858c6e276 100644 --- a/app/src/processing/app/Serial.java +++ b/app/src/processing/app/Serial.java @@ -185,8 +185,11 @@ public class Serial implements SerialPortEventListener { case SerialPortEvent.RXFLAG: try { byte[] bytes = port.readBytes(); + if (bytes == null) { + return; + } String bytesAsString = new String(bytes); - if(monitor) { + if (monitor) { System.out.print(bytesAsString); } if (this.consumer != null) { @@ -199,7 +202,6 @@ public class Serial implements SerialPortEventListener { } - /** * This will handle both ints, bytes and chars transparently. */