Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2015-10-19 01:08:27 +0000
committerDoug Schaefer2015-10-19 01:57:32 +0000
commita657aaa13261d1e2455dcd343c214260b8389fef (patch)
tree446e1f162bf0b618e4f2e16ee08c5eac39df5b39
parent98dee4063b00adfb1b6339e50ce5172a4645f724 (diff)
downloadorg.eclipse.cdt-a657aaa13261d1e2455dcd343c214260b8389fef.tar.gz
org.eclipse.cdt-a657aaa13261d1e2455dcd343c214260b8389fef.tar.xz
org.eclipse.cdt-a657aaa13261d1e2455dcd343c214260b8389fef.zip
Bug 480077 Be more lenient on the *usbserial* port names.
Need to add support for /dev/tty.wchusbserial*. Change-Id: I219070b7464eff1781baa57882c93d4b70032fb2 (cherry picked from commit 652943dfdff297faf3b6e730e60ba600af081016)
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java17
1 files changed, 9 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 b15c7178c8a..07bd5c67356 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
@@ -50,7 +50,7 @@ public class SerialPort {
private byte[] rbuff = new byte[256];
private int rpos = 0;
private int rlen = 0;
-
+
@Override
public int read() throws IOException {
if (isOpen()) {
@@ -120,7 +120,7 @@ public class SerialPort {
SerialPort.this.close();
}
};
-
+
private OutputStream outputStream = new OutputStream() {
@Override
public void write(int b) throws IOException {
@@ -175,7 +175,8 @@ public class SerialPort {
/**
* Create a serial port that connect to the given serial device.
*
- * @param portName name for the serial device.
+ * @param portName
+ * name for the serial device.
*/
public SerialPort(String portName) {
this.portName = portName;
@@ -188,9 +189,9 @@ public class SerialPort {
private native int read1(long handle, byte[] b, int off, int len) throws IOException;
private native void write0(long handle, int b) throws IOException;
-
+
private native void write1(long handle, byte[] b, int off, int len) throws IOException;
-
+
private static native String getPortName(int i) throws IOException;
private static String[] listDevs(final Pattern pattern) {
@@ -201,7 +202,7 @@ public class SerialPort {
return pattern.matcher(name).matches();
}
});
-
+
if (files == null) {
return new String[0];
}
@@ -221,10 +222,10 @@ public class SerialPort {
public static String[] list() throws IOException {
String osName = System.getProperty("os.name"); //$NON-NLS-1$
if (osName.equals("Mac OS X")) { //$NON-NLS-1$
- return listDevs(Pattern.compile("tty\\.(usbserial|usbmodem).*")); //$NON-NLS-1$
+ return listDevs(Pattern.compile("tty\\..*(usbserial|usbmodem).*")); //$NON-NLS-1$
} else if (osName.equals("Linux")) { //$NON-NLS-1$
return listDevs(Pattern.compile("ttyUSB.*")); //$NON-NLS-1$
- } else if (osName.startsWith("Windows")) { //$NON-NLS-1$
+ } else if (osName.startsWith("Windows")) { //$NON-NLS-1$
List<String> ports = new ArrayList<>();
int i = 0;
for (String name = getPortName(i++); name != null; name = getPortName(i++)) {

Back to the top