Skip to content

Commit 9916634

Browse files
author
Federico Fissore
committed
null check on SerialPort.readBytes
1 parent 23086d6 commit 9916634

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: app/src/processing/app/Serial.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ public synchronized void serialEvent(SerialPortEvent serialEvent) {
185185
case SerialPortEvent.RXFLAG:
186186
try {
187187
byte[] bytes = port.readBytes();
188+
if (bytes == null) {
189+
return;
190+
}
188191
String bytesAsString = new String(bytes);
189-
if(monitor) {
192+
if (monitor) {
190193
System.out.print(bytesAsString);
191194
}
192195
if (this.consumer != null) {
@@ -199,7 +202,6 @@ public synchronized void serialEvent(SerialPortEvent serialEvent) {
199202
}
200203

201204

202-
203205
/**
204206
* This will handle both ints, bytes and chars transparently.
205207
*/

0 commit comments

Comments
 (0)