Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
index 9558c87b9b6..62bea0f1ad7 100644
--- a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
@@ -308,7 +308,7 @@ public class SerialPort {
return outputStream;
}
- public void open() throws IOException {
+ public synchronized void open() throws IOException {
handle = open0(portName, baudRate.getRate(), byteSize.getSize(), parity.ordinal(), stopBits.ordinal());
isOpen = true;
@@ -356,18 +356,26 @@ public class SerialPort {
}
public void pause() throws IOException {
- isPaused = true;
- close0(handle);
- try {
- // Sleep for a second since some serial ports take a while to actually close
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // nothing to do
+ if (!isOpen) {
+ return;
+ }
+ synchronized (pauseMutex) {
+ isPaused = true;
+ close0(handle);
+ try {
+ // Sleep for a second since some serial ports take a while to actually close
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // nothing to do
+ }
}
}
public void resume() throws IOException {
synchronized (pauseMutex) {
+ if (!isPaused) {
+ return;
+ }
isPaused = false;
handle = open0(portName, baudRate.getRate(), byteSize.getSize(), parity.ordinal(), stopBits.ordinal());
isOpen = true;

Back to the top