Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2015-04-06 16:51:18 -0400
committerGerrit Code Review @ Eclipse.org2015-04-06 19:39:30 -0400
commit69934151807315f2475ce9e71e8d328b8f1eb51b (patch)
tree356a281986cfc1bf88888e96d72945d53e95860a
parent711ec8df95456d971ee3c6e6c0eeff586cdc6ba1 (diff)
downloadorg.eclipse.cdt-69934151807315f2475ce9e71e8d328b8f1eb51b.tar.gz
org.eclipse.cdt-69934151807315f2475ce9e71e8d328b8f1eb51b.tar.xz
org.eclipse.cdt-69934151807315f2475ce9e71e8d328b8f1eb51b.zip
Bug 459971 - Move serial port to it's own plug-in. Starting with Mac.
There are a number of requests to support serial port independent of CDT and independent of Eclipse. Putting the serial port into it's own plug-in so it's jar can be loaded into pure Java apps. Change-Id: I9b35d9bedeee0a0b1c16ad1c884830894320a726
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/Makefile23
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/serial.c109
-rw-r--r--core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF1
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java1
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties1
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/Parity.java22
-rw-r--r--native/org.eclipse.cdt.native.serial/.classpath7
-rw-r--r--native/org.eclipse.cdt.native.serial/.gitignore1
-rw-r--r--native/org.eclipse.cdt.native.serial/.project28
-rw-r--r--native/org.eclipse.cdt.native.serial/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF8
-rw-r--r--native/org.eclipse.cdt.native.serial/about.html24
-rw-r--r--native/org.eclipse.cdt.native.serial/about.ini24
-rw-r--r--native/org.eclipse.cdt.native.serial/about.mappings9
-rw-r--r--native/org.eclipse.cdt.native.serial/about.properties24
-rw-r--r--native/org.eclipse.cdt.native.serial/build.properties11
-rw-r--r--native/org.eclipse.cdt.native.serial/cdt_logo_icon32.pngbin0 -> 1885 bytes
-rw-r--r--native/org.eclipse.cdt.native.serial/jni/.gitignore1
-rw-r--r--native/org.eclipse.cdt.native.serial/jni/posix/Makefile69
-rw-r--r--native/org.eclipse.cdt.native.serial/jni/posix/serial.c125
-rwxr-xr-xnative/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilibbin0 -> 9492 bytes
-rw-r--r--native/org.eclipse.cdt.native.serial/pom.xml17
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/BaudRate.java92
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/ByteSize.java (renamed from core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/ByteSize.java)44
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/Parity.java55
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java (renamed from core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/SerialPort.java)159
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/StopBits.java (renamed from core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/StopBits.java)35
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/Messages.java (renamed from core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/BaudRate.java)50
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/messages.properties11
-rw-r--r--pom.xml1
-rw-r--r--releng/org.eclipse.cdt.native-feature/feature.xml7
-rw-r--r--releng/org.eclipse.cdt.native.source-feature/feature.xml6
32 files changed, 703 insertions, 269 deletions
diff --git a/core/org.eclipse.cdt.core.macosx/library/Makefile b/core/org.eclipse.cdt.core.macosx/library/Makefile
index 71a5494573..a184aa5f8e 100644
--- a/core/org.eclipse.cdt.core.macosx/library/Makefile
+++ b/core/org.eclipse.cdt.core.macosx/library/Makefile
@@ -51,19 +51,14 @@ LIB_NAME_FULL_PTY_X86_64 = $(INSTALL_DIR_X86_64)/libpty.jnilib
OBJS_PTY_X86 = openpty_$(ARCH_X86).o pty_$(ARCH_X86).o ptyio_$(ARCH_X86).o
OBJS_PTY_X86_64 = openpty_$(ARCH_X86_64).o pty_$(ARCH_X86_64).o ptyio_$(ARCH_X86_64).o
-LIB_NAME_FULL_SERIAL_X86 = $(INSTALL_DIR_X86)/libserial.jnilib
-LIB_NAME_FULL_SERIAL_X86_64 = $(INSTALL_DIR_X86_64)/libserial.jnilib
-OBJS_SERIAL_X86 = serial_$(ARCH_X86).o
-OBJS_SERIAL_X86_64 = serial_$(ARCH_X86_64).o
-
OBJS_X86 = $(OBJS_SPAWNER_X86) $(OBJS_PTY_X86) $(OBJS_SERIAL_X86)
OBJS_X86_64 = $(OBJS_SPAWNER_X86_64) $(OBJS_PTY_X86_64) $(OBJS_SERIAL_X86_64)
all: x86 x86_64
-x86: $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86) $(LIB_NAME_FULL_SERIAL_X86)
+x86: $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86)
-x86_64: $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64) $(LIB_NAME_FULL_SERIAL_X86_64)
+x86_64: $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64)
rebuild: clean all
@@ -83,14 +78,6 @@ $(LIB_NAME_FULL_PTY_X86_64): $(OBJS_PTY_X86_64)
mkdir -p $(INSTALL_DIR_X86_64)
$(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_PTY_X86_64) $(OBJS_PTY_X86_64) -lc -framework JavaVM
-$(LIB_NAME_FULL_SERIAL_X86): $(OBJS_SERIAL_X86)
- mkdir -p $(INSTALL_DIR_X86)
- $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SERIAL_X86) $(OBJS_SERIAL_X86) -lc -framework JavaVM
-
-$(LIB_NAME_FULL_SERIAL_X86_64): $(OBJS_SERIAL_X86_64)
- mkdir -p $(INSTALL_DIR_X86_64)
- $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SERIAL_X86_64) $(OBJS_SERIAL_X86_64) -lc -framework JavaVM
-
spawner_$(ARCH_X86).o: spawner.c
$(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ spawner.c
@@ -115,9 +102,6 @@ pty_$(ARCH_X86).o: pty.c
ptyio_$(ARCH_X86).o: ptyio.c
$(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ ptyio.c
-serial_$(ARCH_X86).o: serial.c
- $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ serial.c
-
spawner_$(ARCH_X86_64).o: spawner.c
$(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ spawner.c
@@ -142,9 +126,6 @@ pty_$(ARCH_X86_64).o: pty.c
ptyio_$(ARCH_X86_64).o: ptyio.c
$(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ ptyio.c
-serial_$(ARCH_X86_64).o: serial.c
- $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ serial.c
-
clean :
$(RM) $(OBJS_X86) $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86)
$(RM) $(OBJS_X86_64) $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64)
diff --git a/core/org.eclipse.cdt.core.macosx/library/serial.c b/core/org.eclipse.cdt.core.macosx/library/serial.c
deleted file mode 100644
index d4cedbaf96..0000000000
--- a/core/org.eclipse.cdt.core.macosx/library/serial.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <jni.h>
-
-JNIEXPORT jlong JNICALL Java_org_eclipse_cdt_utils_serial_SerialPort_open0
-(JNIEnv *env, jobject jobj, jstring portName, jint baudRate, jint byteSize, jint parity, jint stopBits)
-{
- const char * cportName = (*env)->GetStringUTFChars(env, portName, NULL);
- int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
- if (fd >= 0) {
- // Turn off NDELAY
- int flags = fcntl(fd, F_GETFL, 0);
- flags &= ~O_NDELAY;
- fcntl(fd, F_SETFL, flags);
-
- struct termios newtio;
- bzero(&newtio, sizeof(newtio));
- newtio.c_cflag = CLOCAL | CREAD;
-
- cfsetispeed(&newtio, baudRate);
- cfsetospeed(&newtio, baudRate);
-
- switch (byteSize) {
- case 5:
- newtio.c_cflag |= CS5;
- break;
- case 6:
- newtio.c_cflag |= CS6;
- break;
- case 7:
- newtio.c_cflag |= CS7;
- break;
- case 8:
- newtio.c_cflag |= CS8;
- break;
-
- }
-
- switch (parity) {
- case 0: // None
- break;
- case 1: // Even
- newtio.c_cflag |= PARENB;
- break;
- case 2: // Odd
- newtio.c_cflag |= (PARENB | PARODD);
- break;
- }
-
- switch (stopBits) {
- case 0: // 1
- break;
- case 1: // 2
- newtio.c_cflag |= CSTOPB;
- break;
- }
-
- newtio.c_iflag = IGNPAR;
- newtio.c_oflag = 0;
-
- newtio.c_lflag = 0;
-
- newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
- newtio.c_cc[VMIN] = 1; /* blocking read until 5 chars received */
-
- tcflush(fd, TCIFLUSH);
- tcsetattr(fd, TCSANOW, &newtio);
- }
-
- return fd;
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_cdt_utils_serial_SerialPort_close0
-(JNIEnv *env, jobject jobj, jlong handle)
-{
- close(handle);
-}
-
-JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_serial_SerialPort_read0
-(JNIEnv *env, jobject jobj, jlong handle)
-{
- char buff;
- int res = read(handle, &buff, 1);
- return res < 0 ? -1 : buff;
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_cdt_utils_serial_SerialPort_write0
-(JNIEnv *env, jobject jobj, jlong handle, jint b)
-{
- char buff = b;
- write(handle, &buff, 1);
-}
diff --git a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
index 977fbc098b..5eccb27a78 100644
--- a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
@@ -9,7 +9,6 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.core;native=split;mandatory:=native,
org.eclipse.cdt.utils;native=split;mandatory:=native,
org.eclipse.cdt.utils.pty;version="5.7",
- org.eclipse.cdt.utils.serial,
org.eclipse.cdt.utils.spawner;version="5.7"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)"
Bundle-ActivationPolicy: lazy
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java
index d783d90fff..cd406359b4 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java
+++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java
@@ -17,7 +17,6 @@ public class Messages extends NLS {
public static String Util_exception_cannotSetTerminalSize;
public static String Util_error_cannotRun;
public static String Util_exception_closeError;
- public static String SerialPort_PORT_IS_OPEN;
static {
// Initialize resource bundle.
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties
index cc7a5f26a3..e1ab7f1ac4 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties
+++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties
@@ -14,4 +14,3 @@ Util_exception_cannotCreatePty=Cannot create pty
Util_exception_closeError=close error
Util_exception_cannotSetTerminalSize=Setting terminal size is not supported
Util_error_cannotRun=Cannot run program "{0}": {1}
-SerialPort_PORT_IS_OPEN=Port is open
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/Parity.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/Parity.java
deleted file mode 100644
index 81bd15a67f..0000000000
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/Parity.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.utils.serial;
-
-/**
- * @since 5.8
- */
-public enum Parity {
-
- None,
- Even,
- Odd
-
-}
diff --git a/native/org.eclipse.cdt.native.serial/.classpath b/native/org.eclipse.cdt.native.serial/.classpath
new file mode 100644
index 0000000000..098194ca4b
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/native/org.eclipse.cdt.native.serial/.gitignore b/native/org.eclipse.cdt.native.serial/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/native/org.eclipse.cdt.native.serial/.project b/native/org.eclipse.cdt.native.serial/.project
new file mode 100644
index 0000000000..39705da769
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.native.serial</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/native/org.eclipse.cdt.native.serial/.settings/org.eclipse.jdt.core.prefs b/native/org.eclipse.cdt.native.serial/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..f42de363af
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ea6bd38806
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Serial Port
+Bundle-SymbolicName: org.eclipse.cdt.native.serial
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse CDT
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Export-Package: org.eclipse.cdt.serial
diff --git a/native/org.eclipse.cdt.native.serial/about.html b/native/org.eclipse.cdt.native.serial/about.html
new file mode 100644
index 0000000000..d7c511887d
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 22, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/native/org.eclipse.cdt.native.serial/about.ini b/native/org.eclipse.cdt.native.serial/about.ini
new file mode 100644
index 0000000000..e07a7bb377
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/about.ini
@@ -0,0 +1,24 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=cdt_logo_icon32.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
diff --git a/native/org.eclipse.cdt.native.serial/about.mappings b/native/org.eclipse.cdt.native.serial/about.mappings
new file mode 100644
index 0000000000..0824105e69
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/about.mappings
@@ -0,0 +1,9 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+# The following should contain the build version.
+# e.g. "0=20020612"
+# This value will be added automaticaly via the build scripts
+0=@build@ \ No newline at end of file
diff --git a/native/org.eclipse.cdt.native.serial/about.properties b/native/org.eclipse.cdt.native.serial/about.properties
new file mode 100644
index 0000000000..a090552503
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/about.properties
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2002, 2009 Wind River Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Wind River Systems - initial API and implementation
+###############################################################################
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+# NOTE TO TRANSLATOR: Please do not translate the featureVersion variable.
+
+blurb=Eclipse CDT P2 Customizations for SDK installation\n\
+\n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+(c) Copyright Eclipse contributors and others, 2000, 2010. All rights reserved.\n\
+Visit http://www.eclipse.org/cdt
diff --git a/native/org.eclipse.cdt.native.serial/build.properties b/native/org.eclipse.cdt.native.serial/build.properties
new file mode 100644
index 0000000000..6fd7e5923e
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ os/,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ cdt_logo_icon32.png
+src.includes = jni/
diff --git a/native/org.eclipse.cdt.native.serial/cdt_logo_icon32.png b/native/org.eclipse.cdt.native.serial/cdt_logo_icon32.png
new file mode 100644
index 0000000000..470ca81b32
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/cdt_logo_icon32.png
Binary files differ
diff --git a/native/org.eclipse.cdt.native.serial/jni/.gitignore b/native/org.eclipse.cdt.native.serial/jni/.gitignore
new file mode 100644
index 0000000000..5761abcfdf
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/jni/.gitignore
@@ -0,0 +1 @@
+*.o
diff --git a/native/org.eclipse.cdt.native.serial/jni/posix/Makefile b/native/org.eclipse.cdt.native.serial/jni/posix/Makefile
new file mode 100644
index 0000000000..9952967f32
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/jni/posix/Makefile
@@ -0,0 +1,69 @@
+#*******************************************************************************
+# Copyright (c) 2002, 2009 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# QNX Software Systems - initial API and implementation
+# Alex Blewitt - MacOSX with a 64-bit vm
+#*******************************************************************************/
+
+JAVA_HOME = $(shell echo /Library/Java/JavaVirtualMachines/jdk1.8.0_*.jdk/Contents/Home)
+UNAME = $(shell uname)
+
+# Defaults which can be overridden.
+ifeq ($(UNAME),Darwin)
+OS = macosx
+ARCHS = x86_64
+endif
+
+ARCH_X86 = x86
+ARCH_X86_64 = x86_64
+
+CC=gcc
+LD=libtool
+CPPFLAGS = -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
+CFLAGS +=-fPIC -D_REENTRANT
+
+ARCH_FLAG_X86 = -arch i386
+ARCH_FLAG_X86_64 = -arch x86_64
+
+INSTALL_DIR_X86 = ../../os/$(OS)/$(ARCH_X86)
+INSTALL_DIR_X86_64 = ../../os/$(OS)/$(ARCH_X86_64)
+
+LIB_NAME_FULL_SERIAL_X86 = $(INSTALL_DIR_X86)/libserial.jnilib
+LIB_NAME_FULL_SERIAL_X86_64 = $(INSTALL_DIR_X86_64)/libserial.jnilib
+
+OBJS_SERIAL_X86 = serial_$(ARCH_X86).o
+OBJS_SERIAL_X86_64 = serial_$(ARCH_X86_64).o
+
+OBJS_X86 = $(OBJS_SERIAL_X86)
+OBJS_X86_64 = $(OBJS_SERIAL_X86_64)
+
+all: $(ARCHS)
+
+x86: $(LIB_NAME_FULL_SERIAL_X86)
+
+x86_64: $(LIB_NAME_FULL_SERIAL_X86_64)
+
+rebuild: clean all
+
+$(LIB_NAME_FULL_SERIAL_X86): $(OBJS_SERIAL_X86)
+ mkdir -p $(INSTALL_DIR_X86)
+ $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SERIAL_X86) $(OBJS_SERIAL_X86) -lc -framework JavaVM
+
+$(LIB_NAME_FULL_SERIAL_X86_64): $(OBJS_SERIAL_X86_64)
+ mkdir -p $(INSTALL_DIR_X86_64)
+ $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SERIAL_X86_64) $(OBJS_SERIAL_X86_64) -lc -framework JavaVM
+
+serial_$(ARCH_X86).o: serial.c
+ $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ serial.c
+
+serial_$(ARCH_X86_64).o: serial.c
+ $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ serial.c
+
+clean :
+ $(RM) $(OBJS_X86)
+ $(RM) $(OBJS_X86_64)
diff --git a/native/org.eclipse.cdt.native.serial/jni/posix/serial.c b/native/org.eclipse.cdt.native.serial/jni/posix/serial.c
new file mode 100644
index 0000000000..bf1e51da27
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/jni/posix/serial.c
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <jni.h>
+
+#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_ ## x
+
+JNIEXPORT jlong JNICALL FUNC(open0)(JNIEnv *env, jobject jobj, jstring portName, jint baudRate, jint byteSize, jint parity, jint stopBits)
+{
+ const char * cportName = (*env)->GetStringUTFChars(env, portName, NULL);
+ int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
+ if (fd < 0) {
+ return fd;
+ }
+
+ // Turn off all flags
+ fcntl(fd, F_SETFL, 0);
+
+ struct termios options;
+ tcgetattr(fd, &options);
+ options.c_cflag |= (CLOCAL | CREAD);
+
+ // Set baud rate
+ cfsetispeed(&options, baudRate);
+ cfsetospeed(&options, baudRate);
+
+ // set data size
+ options.c_cflag &= ~CSIZE;
+ switch (byteSize) {
+ case 5:
+ options.c_cflag |= CS5;
+ break;
+ case 6:
+ options.c_cflag |= CS6;
+ break;
+ case 7:
+ options.c_cflag |= CS7;
+ break;
+ case 8:
+ options.c_cflag |= CS8;
+ break;
+
+ }
+
+ // set parity
+ switch (parity) {
+ case 0: // None
+ options.c_cflag &= ~PARENB;
+ break;
+ case 1: // Even
+ options.c_cflag |= PARENB;
+ options.c_cflag &= ~PARODD;
+ break;
+ case 2: // Odd
+ options.c_cflag |= (PARENB | PARODD);
+ break;
+ }
+
+ switch (stopBits) {
+ case 0: // 1
+ options.c_cflag &= ~CSTOPB;
+ break;
+ case 1: // 2
+ options.c_cflag |= CSTOPB;
+ break;
+ }
+
+ // raw input
+ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+
+ // ignore parity
+ options.c_iflag |= IGNPAR;
+
+ options.c_cc[VMIN] = 0; // min chars to read
+ options.c_cc[VTIME] = 10; // 10ths second timeout
+
+ tcflush(fd, TCIFLUSH);
+ tcsetattr(fd, TCSANOW, &options);
+
+ return fd;
+}
+
+JNIEXPORT void JNICALL FUNC(close0)(JNIEnv *env, jobject jobj, jlong handle)
+ {
+ close(handle);
+ }
+
+JNIEXPORT jint JNICALL FUNC(read0)(JNIEnv *env, jobject jobj, jlong handle)
+ {
+ char buff;
+ int res = read(handle, &buff, 1);
+ return res < 0 ? -1 : buff;
+ }
+
+JNIEXPORT jint JNICALL FUNC(read1)(JNIEnv * env, jobject jobj, jlong handle, jbyteArray bytes, jint offset, jint size) {
+ jbyte buff[256];
+ int n = size < sizeof(buff) ? size : sizeof(buff);
+ n = read(handle, buff, n);
+ if (n > 0) {
+ (*env)->SetByteArrayRegion(env, bytes, offset, n, buff);
+ }
+ return n;
+}
+
+JNIEXPORT void JNICALL FUNC(write0)(JNIEnv *env, jobject jobj, jlong handle, jint b)
+ {
+ char buff = b;
+ write(handle, &buff, 1);
+ }
diff --git a/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib b/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib
new file mode 100755
index 0000000000..bf96f91430
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib
Binary files differ
diff --git a/native/org.eclipse.cdt.native.serial/pom.xml b/native/org.eclipse.cdt.native.serial/pom.xml
new file mode 100644
index 0000000000..71d47f62c6
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.6.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.native.serial</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/BaudRate.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/BaudRate.java
new file mode 100644
index 0000000000..70965fdeed
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/BaudRate.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.serial;
+
+/**
+ * @since 1.0
+ */
+public enum BaudRate {
+
+ B110(110),
+ B300(300),
+ B600(600),
+ B1200(1200),
+ B2400(2400),
+ B4800(4800),
+ B9600(9600),
+ B14400(14400),
+ B19200(19200),
+ B38400(38400),
+ B57600(57600),
+ B115200(115200);
+
+ private final int rate;
+
+ private BaudRate(int rate) {
+ this.rate = rate;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ private static final String[] strings = {
+ "110", //$NON-NLS-1$
+ "300", //$NON-NLS-1$
+ "600", //$NON-NLS-1$
+ "1200", //$NON-NLS-1$
+ "2400", //$NON-NLS-1$
+ "4800", //$NON-NLS-1$
+ "9600", //$NON-NLS-1$
+ "14400", //$NON-NLS-1$
+ "19200", //$NON-NLS-1$
+ "38400", //$NON-NLS-1$
+ "57600", //$NON-NLS-1$
+ "115200" //$NON-NLS-1$
+ };
+
+ public static String[] getStrings() {
+ return strings;
+ }
+
+ private static final BaudRate[] rates = {
+ B110,
+ B300,
+ B600,
+ B1200,
+ B2400,
+ B4800,
+ B9600,
+ B14400,
+ B19200,
+ B38400,
+ B57600,
+ B115200
+ };
+
+ public static BaudRate fromStringIndex(int rate) {
+ return rates[rate];
+ }
+
+ public static int getStringIndex(BaudRate rate) {
+ for (int i = 0; i < rates.length; ++i) {
+ if (rate.equals(rates[i])) {
+ return i;
+ }
+ }
+ return getStringIndex(getDefault());
+ }
+
+ public static BaudRate getDefault() {
+ return B9600;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/ByteSize.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/ByteSize.java
index b570b729a7..ad37c63afc 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/ByteSize.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/ByteSize.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.utils.serial;
+package org.eclipse.cdt.serial;
/**
* @since 5.8
@@ -19,14 +19,50 @@ public enum ByteSize {
B6(6),
B7(7),
B8(8);
-
+
private final int size;
-
+
private ByteSize(int size) {
this.size = size;
}
-
+
public int getSize() {
return size;
}
+
+ private static final String[] strings = {
+ "5", //$NON-NLS-1$
+ "6", //$NON-NLS-1$
+ "7", //$NON-NLS-1$
+ "8" //$NON-NLS-1$
+ };
+
+ public static String[] getStrings() {
+ return strings;
+ }
+
+ private static final ByteSize[] sizes = {
+ B5,
+ B6,
+ B7,
+ B8
+ };
+
+ public static ByteSize fromStringIndex(int size) {
+ return sizes[size];
+ }
+
+ public static int getStringIndex(ByteSize size) {
+ for (int i = 0; i < sizes.length; ++i) {
+ if (size.equals(sizes[i])) {
+ return i;
+ }
+ }
+ return getStringIndex(getDefault());
+ }
+
+ public static ByteSize getDefault() {
+ return B8;
+ }
+
}
diff --git a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/Parity.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/Parity.java
new file mode 100644
index 0000000000..c93fa815d1
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/Parity.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.serial;
+
+/**
+ * @since 5.8
+ */
+public enum Parity {
+
+ None,
+ Even,
+ Odd;
+
+ private static final String[] strings = {
+ "None", //$NON-NLS-1$
+ "Even", //$NON-NLS-1$
+ "Odd" //$NON-NLS-1$
+ };
+
+ public static String[] getStrings() {
+ return strings;
+ }
+
+ private static final Parity[] parities = {
+ None,
+ Even,
+ Odd
+ };
+
+ public static Parity fromStringIndex(int index) {
+ return parities[index];
+ }
+
+ public static int getStringIndex(Parity parity) {
+ for (int i = 0; i < parities.length; ++i) {
+ if (parity.equals(parities[i])) {
+ return i;
+ }
+ }
+ return getStringIndex(getDefault());
+ }
+
+ public static Parity getDefault() {
+ return None;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/SerialPort.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
index d47da52f1a..62c7a9bdab 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/SerialPort.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
@@ -8,21 +8,16 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.utils.serial;
+package org.eclipse.cdt.serial;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
import java.util.regex.Pattern;
-import org.eclipse.cdt.internal.core.natives.CNativePlugin;
-import org.eclipse.cdt.internal.core.natives.Messages;
-import org.eclipse.cdt.utils.WindowsRegistry;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.cdt.serial.internal.Messages;
/**
* @since 5.8
@@ -38,16 +33,55 @@ public class SerialPort {
private long handle;
private static final String SERIAL_KEY = "HARDWARE\\DEVICEMAP\\SERIALCOMM"; //$NON-NLS-1$
- private static final String PORT_OPEN = Messages.SerialPort_PORT_IS_OPEN;
+ private static final String PORT_OPEN = Messages.getString("SerialPort.PortIsOpen"); //$NON-NLS-1$
static {
try {
System.loadLibrary("serial"); //$NON-NLS-1$
- } catch (Exception e) {
- CNativePlugin.log(e);
+ } catch (UnsatisfiedLinkError e) {
+ e.printStackTrace();
}
}
+ private InputStream inputStream = new InputStream() {
+ @Override
+ public int read() throws IOException {
+ if (isOpen()) {
+ return read0(handle);
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (isOpen()) {
+ return read1(handle, b, off, len);
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ SerialPort.this.close();
+ }
+ };
+
+ private OutputStream outputStream = new OutputStream() {
+ @Override
+ public void write(int b) throws IOException {
+ if (isOpen()) {
+ write0(handle, b);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ SerialPort.this.close();
+ }
+ };
+
/**
* Create a serial port that connect to the given serial device.
*
@@ -63,7 +97,7 @@ public class SerialPort {
* @return serial ports
*/
public static String[] list() {
- if (Platform.getOS().equals(Platform.OS_MACOSX)) {
+ if (System.getProperty("os.name").equals("Mac OS X")) { //$NON-NLS-1$//$NON-NLS-2$
File dev = new File("/dev"); //$NON-NLS-1$
final Pattern pattern = Pattern.compile("tty\\.(usbserial|usbmodem).*"); //$NON-NLS-1$
File[] files = dev.listFiles(new FilenameFilter() {
@@ -81,27 +115,38 @@ public class SerialPort {
names[i] = files[i].getAbsolutePath();
}
return names;
- } else if (Platform.getOS().equals(Platform.OS_WIN32)) {
- WindowsRegistry reg = WindowsRegistry.getRegistry();
- if (reg != null) {
- List<String> ports = new ArrayList<>();
- int i = 0;
- String name = reg.getLocalMachineValueName(SERIAL_KEY, i);
- while (name != null) {
- String value = reg.getLocalMachineValue(SERIAL_KEY, name);
- ports.add(value);
- i++;
- name = reg.getLocalMachineValueName(SERIAL_KEY, i);
- }
- return ports.toArray(new String[ports.size()]);
- } else {
- return new String[0];
- }
+ } else if (System.getProperty("os.name").equals("Windows NT")) { //$NON-NLS-1$//$NON-NLS-2$
+// WindowsRegistry reg = WindowsRegistry.getRegistry();
+// if (reg != null) {
+// List<String> ports = new ArrayList<>();
+// int i = 0;
+// String name = reg.getLocalMachineValueName(SERIAL_KEY, i);
+// while (name != null) {
+// String value = reg.getLocalMachineValue(SERIAL_KEY, name);
+// ports.add(value);
+// i++;
+// name = reg.getLocalMachineValueName(SERIAL_KEY, i);
+// }
+// return ports.toArray(new String[ports.size()]);
+// } else {
+// return new String[0];
+// }
+ return new String[0];
} else {
return new String[0];
}
}
+ private native long open0(String portName, int baudRate, int byteSize, int parity, int stopBits) throws IOException;
+
+ private native void close0(long handle) throws IOException;
+
+ private native int read0(long handle) throws IOException;
+
+ private native int read1(long handle, byte[] b, int off, int len);
+
+ private native void write0(long handle, int b) throws IOException;
+
/**
* Return the name for this serial port.
*
@@ -111,21 +156,27 @@ public class SerialPort {
return portName;
}
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ public OutputStream getOutputStream() {
+ return outputStream;
+ }
+
public void open() throws IOException {
handle = open0(portName, baudRate.getRate(), byteSize.getSize(), parity.ordinal(), stopBits.ordinal());
isOpen = true;
}
- private native long open0(String portName, int baudRate, int byteSize, int parity, int stopBits) throws IOException;
-
- public void close() throws IOException {
- close0(handle);
- isOpen = false;
- handle = 0;
+ public synchronized void close() throws IOException {
+ if (isOpen) {
+ close0(handle);
+ isOpen = false;
+ handle = 0;
+ }
}
- private native void close0(long handle) throws IOException;
-
public boolean isOpen() {
return isOpen;
}
@@ -174,42 +225,4 @@ public class SerialPort {
return stopBits;
}
- public InputStream getInputStream() {
- return new InputStream() {
- @Override
- public int read() throws IOException {
- if (isOpen()) {
- return read0(handle);
- } else {
- return -1;
- }
- }
-
- @Override
- public void close() throws IOException {
- SerialPort.this.close();
- }
- };
- }
-
- private native int read0(long handle) throws IOException;
-
- public OutputStream getOutputStream() {
- return new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- if (isOpen()) {
- write0(handle, b);
- }
- }
-
- @Override
- public void close() throws IOException {
- SerialPort.this.close();
- }
- };
- }
-
- private native void write0(long handle, int b) throws IOException;
-
}
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/StopBits.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/StopBits.java
index bd8069bf0d..92752ce8e1 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/StopBits.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/StopBits.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.utils.serial;
+package org.eclipse.cdt.serial;
/**
* @since 5.8
@@ -16,6 +16,37 @@ package org.eclipse.cdt.utils.serial;
public enum StopBits {
S1,
- S2
+ S2;
+
+ private static final String[] strings = {
+ "1", //$NON-NLS-1$
+ "2" //$NON-NLS-1$
+ };
+
+ public static String[] getStrings() {
+ return strings;
+ }
+
+ private static final StopBits[] stopBits = {
+ S1,
+ S2
+ };
+
+ public static StopBits fromStringIndex(int index) {
+ return stopBits[index];
+ }
+ public static int getStringIndex(StopBits sb) {
+ for (int i = 0; i < stopBits.length; ++i) {
+ if (sb.equals(stopBits[i])) {
+ return i;
+ }
+ }
+ return getStringIndex(getDefault());
+ }
+
+ public static StopBits getDefault() {
+ return S1;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/BaudRate.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/Messages.java
index 8c1342339f..45a3d53817 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/serial/BaudRate.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/Messages.java
@@ -8,44 +8,24 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.utils.serial;
+package org.eclipse.cdt.serial.internal;
-/**
- * @since 5.8
- */
-public enum BaudRate {
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
- B50(50),
- B75(75),
- B110(110),
- B134(134),
- B150(150),
- B200(200),
- B300(300),
- B600(600),
- B1200(1200),
- B1800(1800),
- B2400(2400),
- B4800(4800),
- B7200(7200),
- B9600(9600),
- B14400(14400),
- B19200(19200),
- B28800(28800),
- B38400(38400),
- B57600(57600),
- B76800(76800),
- B115200(115200),
- B230400(230400);
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.serial.internal.messages"; //$NON-NLS-1$
- private final int rate;
-
- private BaudRate(int rate) {
- this.rate = rate;
- }
-
- public int getRate() {
- return rate;
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages() {
}
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
}
diff --git a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/messages.properties b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/messages.properties
new file mode 100644
index 0000000000..9a39f7958c
--- /dev/null
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/internal/messages.properties
@@ -0,0 +1,11 @@
+##################################################################################
+# Copyright (c) 2015 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# QNX Software Systems - initial API and implementation
+##################################################################################
+SerialPort.PortIsOpen=Port is open
diff --git a/pom.xml b/pom.xml
index ffabd3d484..3eef02c47d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
<module>core/org.eclipse.cdt.core.macosx</module>
<module>core/org.eclipse.cdt.core.aix</module>
<module>core/org.eclipse.cdt.core.solaris</module>
+ <module>native/org.eclipse.cdt.native.serial</module>
<module>releng/org.eclipse.cdt.native-feature</module>
<module>releng/org.eclipse.cdt.native.source-feature</module>
diff --git a/releng/org.eclipse.cdt.native-feature/feature.xml b/releng/org.eclipse.cdt.native-feature/feature.xml
index 6334916f67..e0c88aaf5a 100644
--- a/releng/org.eclipse.cdt.native-feature/feature.xml
+++ b/releng/org.eclipse.cdt.native-feature/feature.xml
@@ -130,4 +130,11 @@
version="0.0.0"
fragment="true"/>
+ <plugin
+ id="org.eclipse.cdt.native.serial"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/releng/org.eclipse.cdt.native.source-feature/feature.xml b/releng/org.eclipse.cdt.native.source-feature/feature.xml
index 1289221563..0a0595b52f 100644
--- a/releng/org.eclipse.cdt.native.source-feature/feature.xml
+++ b/releng/org.eclipse.cdt.native.source-feature/feature.xml
@@ -71,5 +71,11 @@
version="0.0.0"
fragment="true"/>
+ <plugin
+ id="org.eclipse.cdt.native.serial.source"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
</feature>

Back to the top