mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
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
This commit is contained in:
parent
711ec8df95
commit
6993415180
32 changed files with 703 additions and 269 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
7
native/org.eclipse.cdt.native.serial/.classpath
Normal file
7
native/org.eclipse.cdt.native.serial/.classpath
Normal file
|
@ -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>
|
1
native/org.eclipse.cdt.native.serial/.gitignore
vendored
Normal file
1
native/org.eclipse.cdt.native.serial/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/bin/
|
28
native/org.eclipse.cdt.native.serial/.project
Normal file
28
native/org.eclipse.cdt.native.serial/.project
Normal file
|
@ -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>
|
|
@ -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
|
|
@ -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
|
24
native/org.eclipse.cdt.native.serial/about.html
Normal file
24
native/org.eclipse.cdt.native.serial/about.html
Normal file
|
@ -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>
|
24
native/org.eclipse.cdt.native.serial/about.ini
Normal file
24
native/org.eclipse.cdt.native.serial/about.ini
Normal file
|
@ -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
|
9
native/org.eclipse.cdt.native.serial/about.mappings
Normal file
9
native/org.eclipse.cdt.native.serial/about.mappings
Normal file
|
@ -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@
|
24
native/org.eclipse.cdt.native.serial/about.properties
Normal file
24
native/org.eclipse.cdt.native.serial/about.properties
Normal file
|
@ -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
|
11
native/org.eclipse.cdt.native.serial/build.properties
Normal file
11
native/org.eclipse.cdt.native.serial/build.properties
Normal file
|
@ -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/
|
BIN
native/org.eclipse.cdt.native.serial/cdt_logo_icon32.png
Normal file
BIN
native/org.eclipse.cdt.native.serial/cdt_logo_icon32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
1
native/org.eclipse.cdt.native.serial/jni/.gitignore
vendored
Normal file
1
native/org.eclipse.cdt.native.serial/jni/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.o
|
69
native/org.eclipse.cdt.native.serial/jni/posix/Makefile
Normal file
69
native/org.eclipse.cdt.native.serial/jni/posix/Makefile
Normal file
|
@ -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)
|
125
native/org.eclipse.cdt.native.serial/jni/posix/serial.c
Normal file
125
native/org.eclipse.cdt.native.serial/jni/posix/serial.c
Normal file
|
@ -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);
|
||||
}
|
BIN
native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib
Executable file
BIN
native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib
Executable file
Binary file not shown.
17
native/org.eclipse.cdt.native.serial/pom.xml
Normal file
17
native/org.eclipse.cdt.native.serial/pom.xml
Normal file
|
@ -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>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 + '!';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
1
pom.xml
1
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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue