1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-01 23:29:28 +01:00

null check on SerialPort.readBytes

This commit is contained in:
Federico Fissore 2013-02-26 17:42:55 +01:00
parent 23086d6b35
commit 991663409a

View File

@ -185,6 +185,9 @@ public class Serial implements SerialPortEventListener {
case SerialPortEvent.RXFLAG: case SerialPortEvent.RXFLAG:
try { try {
byte[] bytes = port.readBytes(); byte[] bytes = port.readBytes();
if (bytes == null) {
return;
}
String bytesAsString = new String(bytes); String bytesAsString = new String(bytes);
if (monitor) { if (monitor) {
System.out.print(bytesAsString); System.out.print(bytesAsString);
@ -199,7 +202,6 @@ public class Serial implements SerialPortEventListener {
} }
/** /**
* This will handle both ints, bytes and chars transparently. * This will handle both ints, bytes and chars transparently.
*/ */