diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index 7824d9b..3598629 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -351,6 +351,10 @@ public final class SerialPort if (isOpened) return true; + // Force a sleep to ensure that the port does not become unusable due to rapid closing/opening on the part of the user + if (safetySleepTime > 0) + try { Thread.sleep(safetySleepTime); } catch (Exception e) { e.printStackTrace(); } + // If this is an Android root application, we must explicitly allow serial port access to the library if (isAndroid) { @@ -382,10 +386,6 @@ public final class SerialPort } } - // Force a sleep to ensure that the port does not become unusable due to rapid closing/opening on the part of the user - if (safetySleepTime > 0) - try { Thread.sleep(safetySleepTime); } catch (Exception e) { e.printStackTrace(); } - if ((portHandle = openPortNative()) > 0) { inputStream = new SerialPortInputStream();