From c943df001f2190c64854c8ef1c85ec5f46854d98 Mon Sep 17 00:00:00 2001 From: hedgecrw85 Date: Mon, 5 Dec 2016 14:51:06 -0600 Subject: [PATCH] Ensure that port reads do not block indefinitely if a user enters an incorrect timeout value (<100) on Linux or Mac. --- src/main/java/com/fazecast/jSerialComm/SerialPort.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index ad05597..845d70d 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -657,6 +657,8 @@ public final class SerialPort readTimeout = newReadTimeout; writeTimeout = newWriteTimeout; } + else if ((newReadTimeout > 0) && (newReadTimeout <= 100)) + readTimeout = 100; else readTimeout = Math.round((float)newReadTimeout / 100.0f) * 100;