mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 09:45:39 +02:00
Bug 486307 - Throw exception when serial connection fails.
Build windows using mingw cross on Ubuntu. Clean up Makefiles and remove unused Windows code. Change-Id: Ic2d36ddbef7e4eecfcee12a496b923326c8a51c6 Signed-off-by: Jonathan Williams <jonwilliams@qnx.com>
This commit is contained in:
parent
a896eee7e9
commit
e44726097c
18 changed files with 490 additions and 762 deletions
58
native/org.eclipse.cdt.native.serial/jni/Makefile
Normal file
58
native/org.eclipse.cdt.native.serial/jni/Makefile
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#*******************************************************************************
|
||||||
|
# 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
|
||||||
|
#*******************************************************************************/
|
||||||
|
|
||||||
|
ifeq ($(JAVA_HOME),)
|
||||||
|
$(error Please define JAVA_HOME)
|
||||||
|
endif
|
||||||
|
|
||||||
|
OS_DIR = ../os
|
||||||
|
|
||||||
|
UNAME = $(shell uname)
|
||||||
|
ifeq ($(UNAME),Linux)
|
||||||
|
LIBS = \
|
||||||
|
$(OS_DIR)/win32/x86/serial.dll \
|
||||||
|
$(OS_DIR)/win32/x86_64/serial.dll \
|
||||||
|
$(OS_DIR)/linux/x86/libserial.so \
|
||||||
|
$(OS_DIR)/linux/x86_64/libserial.so
|
||||||
|
else
|
||||||
|
ifeq ($(UNAME),Darwin)
|
||||||
|
LIBS = \
|
||||||
|
$(OS_DIR)/macosx/x86_64/libserial.jnilib
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: $(LIBS)
|
||||||
|
|
||||||
|
clean :
|
||||||
|
rm $(LIBS)
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|
||||||
|
$(OS_DIR)/win32/x86/serial.dll: serial.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
i686-w64-mingw32-gcc -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -shared -o $@ serial.c
|
||||||
|
|
||||||
|
$(OS_DIR)/win32/x86_64/serial.dll: serial.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
x86_64-w64-mingw32-gcc -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -shared -o $@ serial.c
|
||||||
|
|
||||||
|
$(OS_DIR)/linux/x86/libserial.so: serial.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
gcc -m32 -fPIC -D_REENTRANT -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -shared -o $@ serial.c
|
||||||
|
|
||||||
|
$(OS_DIR)/linux/x86_64/libserial.so: serial.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
gcc -m64 -fPIC -D_REENTRANT -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -shared -o $@ serial.c
|
||||||
|
|
||||||
|
$(OS_DIR)/macosx/x86_64/libserial.jnilib: serial.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
clang -fPIC -D_REENTRANT -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -dynamiclib -o $@ serial.c
|
|
@ -1,82 +0,0 @@
|
||||||
#*******************************************************************************
|
|
||||||
# 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
|
|
||||||
#*******************************************************************************/
|
|
||||||
|
|
||||||
UNAME = $(shell uname)
|
|
||||||
|
|
||||||
# Defaults which can be overridden.
|
|
||||||
ifeq ($(UNAME),Darwin)
|
|
||||||
JAVA_HOME = $(shell echo /Library/Java/JavaVirtualMachines/jdk1.8.0_*.jdk/Contents/Home)
|
|
||||||
OS = macosx
|
|
||||||
JNI_OS = darwin
|
|
||||||
ARCHS = x86_64
|
|
||||||
ARCH_FLAG_X86 = -arch i386
|
|
||||||
ARCH_FLAG_X86_64 = -arch x86_64
|
|
||||||
LDFLAGS = -dynamiclib
|
|
||||||
LIBEXT = jnilib
|
|
||||||
else
|
|
||||||
ifeq ($(UNAME),Linux)
|
|
||||||
JAVA_HOME = /usr/lib/jvm/java-8-oracle
|
|
||||||
OS = linux
|
|
||||||
JNI_OS = linux
|
|
||||||
ARCHS = x86 x86_64
|
|
||||||
ARCH_FLAG_X86 = -m32
|
|
||||||
ARCH_FLAG_X86_64 = -m64
|
|
||||||
LDFLAGS = -shared
|
|
||||||
LIBEXT = so
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ARCH_X86 = x86
|
|
||||||
ARCH_X86_64 = x86_64
|
|
||||||
|
|
||||||
CC=gcc
|
|
||||||
LD=libtool
|
|
||||||
CPPFLAGS = -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(JNI_OS)
|
|
||||||
CFLAGS +=-fPIC -D_REENTRANT
|
|
||||||
|
|
||||||
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.$(LIBEXT)
|
|
||||||
LIB_NAME_FULL_SERIAL_X86_64 = $(INSTALL_DIR_X86_64)/libserial.$(LIBEXT)
|
|
||||||
|
|
||||||
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) $(LDFLAGS) $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SERIAL_X86) $(OBJS_SERIAL_X86)
|
|
||||||
|
|
||||||
$(LIB_NAME_FULL_SERIAL_X86_64): $(OBJS_SERIAL_X86_64)
|
|
||||||
mkdir -p $(INSTALL_DIR_X86_64)
|
|
||||||
$(CC) $(LDFLAGS) $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SERIAL_X86_64) $(OBJS_SERIAL_X86_64)
|
|
||||||
|
|
||||||
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)
|
|
|
@ -1,137 +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
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#endif
|
|
||||||
#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) {
|
|
||||||
perror(cportName);
|
|
||||||
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] = 2; // 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(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL FUNC(write1)(JNIEnv *env, jobject jobj, jlong handle, jbyteArray bytes, jint offset, jint size)
|
|
||||||
{
|
|
||||||
while (size > 0) {
|
|
||||||
jbyte buff[256];
|
|
||||||
int n = size < sizeof(buff) ? size : sizeof(buff);
|
|
||||||
(*env)->GetByteArrayRegion(env, bytes, offset, n, buff);
|
|
||||||
n = write(handle, buff, n);
|
|
||||||
if (n < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
size -= n;
|
|
||||||
offset += n;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,242 +1,432 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2015 QNX Software Systems and others.
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
#include "stdafx.h"
|
#ifdef __APPLE__
|
||||||
|
#include <sys/types.h>
|
||||||
#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_ ## x
|
#include <sys/stat.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
static void throwIOException(JNIEnv *env, char *msg) {
|
#endif
|
||||||
char buff[256];
|
#ifndef __MINGW32__
|
||||||
sprintf_s(buff, sizeof(buff), "%s: %d", msg, GetLastError());
|
#include <unistd.h>
|
||||||
jclass cls = env->FindClass("java/io/IOException");
|
#include <fcntl.h>
|
||||||
env->ThrowNew(cls, buff);
|
#include <termios.h>
|
||||||
}
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
extern "C"
|
#include <string.h>
|
||||||
JNIEXPORT jlong JNICALL FUNC(open0)(JNIEnv *env, jobject jobj, jstring portName, jint baudRate, jint byteSize, jint parity, jint stopBits)
|
#include <strings.h>
|
||||||
{
|
#include <errno.h>
|
||||||
const wchar_t * cportName = (const wchar_t *)env->GetStringChars(portName, NULL);
|
#else
|
||||||
HANDLE handle = CreateFile(cportName,
|
#define WIN32_LEAN_AND_MEAN
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
#define UNICODE
|
||||||
0,
|
#include <windows.h>
|
||||||
NULL,
|
#endif
|
||||||
OPEN_EXISTING,
|
#include <jni.h>
|
||||||
FILE_FLAG_OVERLAPPED,
|
|
||||||
NULL);
|
#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_ ## x
|
||||||
|
|
||||||
if (handle == INVALID_HANDLE_VALUE) {
|
static void throwIOException(JNIEnv *env, const char *msg)
|
||||||
throwIOException(env, "Error opening serial port");
|
{
|
||||||
return -1;
|
char buff[256];
|
||||||
}
|
#ifndef __MINGW32__
|
||||||
|
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||||
DCB dcb = { 0 };
|
#else
|
||||||
|
sprintf_s(buff, sizeof(buff), "%s: %d", msg, GetLastError());
|
||||||
if (!GetCommState(handle, &dcb)) {
|
#endif
|
||||||
throwIOException(env, "Error getting DCB");
|
jclass cls = (*env)->FindClass(env, "java/io/IOException");
|
||||||
return -1;
|
(*env)->ThrowNew(env, cls, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcb.BaudRate = baudRate;
|
JNIEXPORT jlong JNICALL FUNC(open0)(JNIEnv *env, jobject jobj, jstring portName, jint baudRate, jint byteSize, jint parity, jint stopBits)
|
||||||
dcb.ByteSize = (BYTE)byteSize;
|
{
|
||||||
|
#ifndef __MINGW32__
|
||||||
switch (parity) {
|
const char * cportName = (*env)->GetStringUTFChars(env, portName, NULL);
|
||||||
case 0: // None
|
int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||||
dcb.fParity = FALSE;
|
if (fd < 0) {
|
||||||
break;
|
char msg[256];
|
||||||
case 1: // Even
|
sprintf(msg, "Error opening %s", cportName);
|
||||||
dcb.fParity = TRUE;
|
throwIOException(env, msg);
|
||||||
dcb.Parity = EVENPARITY;
|
return fd;
|
||||||
break;
|
}
|
||||||
case 2: // Odd
|
|
||||||
dcb.fParity = TRUE;
|
// Turn off all flags
|
||||||
dcb.Parity = ODDPARITY;
|
fcntl(fd, F_SETFL, 0);
|
||||||
break;
|
|
||||||
}
|
struct termios options;
|
||||||
|
tcgetattr(fd, &options);
|
||||||
switch (stopBits) {
|
options.c_cflag |= (CLOCAL | CREAD);
|
||||||
case 0:
|
|
||||||
dcb.StopBits = ONESTOPBIT;
|
speed_t baud;
|
||||||
break;
|
switch (baudRate) {
|
||||||
case 1:
|
case 110:
|
||||||
dcb.StopBits = TWOSTOPBITS;
|
baud = B110;
|
||||||
break;
|
break;
|
||||||
}
|
case 300:
|
||||||
|
baud = B300;
|
||||||
if (!SetCommState(handle, &dcb)) {
|
break;
|
||||||
throwIOException(env, "Error setting DCB");
|
case 600:
|
||||||
return -1;
|
baud = B600;
|
||||||
}
|
break;
|
||||||
|
case 1200:
|
||||||
COMMTIMEOUTS timeouts = { 0 };
|
baud = B1200;
|
||||||
timeouts.ReadIntervalTimeout = MAXDWORD;
|
break;
|
||||||
timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
|
case 2400:
|
||||||
timeouts.ReadTotalTimeoutConstant = 200;
|
baud = B2400;
|
||||||
if (!SetCommTimeouts(handle, &timeouts)) {
|
break;
|
||||||
throwIOException(env, "Error setting timeouts");
|
case 4800:
|
||||||
return -1;
|
baud = B4800;
|
||||||
}
|
break;
|
||||||
|
case 9600:
|
||||||
return (jlong)handle;
|
baud = B9600;
|
||||||
}
|
break;
|
||||||
|
case 19200:
|
||||||
extern "C"
|
baud = B19200;
|
||||||
JNIEXPORT void JNICALL FUNC(close0)(JNIEnv *env, jobject jobj, jlong handle)
|
break;
|
||||||
{
|
case 38400:
|
||||||
CloseHandle((HANDLE)handle);
|
baud = B38400;
|
||||||
}
|
break;
|
||||||
|
case 57600:
|
||||||
extern "C"
|
baud = B57600;
|
||||||
JNIEXPORT jint JNICALL FUNC(read1)(JNIEnv * env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size)
|
break;
|
||||||
{
|
case 115200:
|
||||||
OVERLAPPED olp = { 0 };
|
baud = B115200;
|
||||||
|
break;
|
||||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
default:
|
||||||
if (olp.hEvent == NULL) {
|
baud = B115200;
|
||||||
throwIOException(env, "Error creating event");
|
}
|
||||||
return -1;
|
// Set baud rate
|
||||||
}
|
cfsetispeed(&options, baud);
|
||||||
|
cfsetospeed(&options, baud);
|
||||||
char buff[256];
|
|
||||||
DWORD nread = sizeof(buff) < size ? sizeof(buff) : size;
|
// set data size
|
||||||
HANDLE handle = (HANDLE)jhandle;
|
options.c_cflag &= ~CSIZE;
|
||||||
|
switch (byteSize) {
|
||||||
if (!ReadFile(handle, buff, sizeof(buff), &nread, &olp)) {
|
case 5:
|
||||||
if (GetLastError() != ERROR_IO_PENDING) {
|
options.c_cflag |= CS5;
|
||||||
throwIOException(env, "Error reading from port");
|
break;
|
||||||
CloseHandle(olp.hEvent);
|
case 6:
|
||||||
return -1;
|
options.c_cflag |= CS6;
|
||||||
}
|
break;
|
||||||
else {
|
case 7:
|
||||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
options.c_cflag |= CS7;
|
||||||
case WAIT_OBJECT_0:
|
break;
|
||||||
if (!GetOverlappedResult(handle, &olp, &nread, FALSE)) {
|
case 8:
|
||||||
if (GetLastError() != ERROR_OPERATION_ABORTED) {
|
options.c_cflag |= CS8;
|
||||||
throwIOException(env, "Error waiting for read");
|
break;
|
||||||
}
|
|
||||||
CloseHandle(olp.hEvent);
|
}
|
||||||
return -1;
|
|
||||||
}
|
// set parity
|
||||||
break;
|
switch (parity) {
|
||||||
}
|
case 0: // None
|
||||||
}
|
options.c_cflag &= ~PARENB;
|
||||||
}
|
break;
|
||||||
|
case 1: // Even
|
||||||
if (nread > 0) {
|
options.c_cflag |= PARENB;
|
||||||
env->SetByteArrayRegion(bytes, offset, nread, (jbyte *)buff);
|
options.c_cflag &= ~PARODD;
|
||||||
}
|
break;
|
||||||
CloseHandle(olp.hEvent);
|
case 2: // Odd
|
||||||
return nread;
|
options.c_cflag |= (PARENB | PARODD);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
extern "C"
|
|
||||||
JNIEXPORT void JNICALL FUNC(write0)(JNIEnv *env, jobject jobj, jlong jhandle, jint b)
|
switch (stopBits) {
|
||||||
{
|
case 0: // 1
|
||||||
OVERLAPPED olp = { 0 };
|
options.c_cflag &= ~CSTOPB;
|
||||||
|
break;
|
||||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
case 1: // 2
|
||||||
if (olp.hEvent == NULL) {
|
options.c_cflag |= CSTOPB;
|
||||||
throwIOException(env, "Error creating event");
|
break;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
// raw input
|
||||||
char buff = (char)b;
|
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||||
DWORD nwritten;
|
|
||||||
HANDLE handle = (HANDLE)jhandle;
|
// ignore parity
|
||||||
|
options.c_iflag |= IGNPAR;
|
||||||
if (!WriteFile(handle, &buff, sizeof(buff), &nwritten, &olp)) {
|
|
||||||
if (GetLastError() != ERROR_IO_PENDING) {
|
options.c_cc[VMIN] = 0; // min chars to read
|
||||||
throwIOException(env, "Error writing to port");
|
options.c_cc[VTIME] = 2; // 10ths second timeout
|
||||||
}
|
|
||||||
else {
|
tcflush(fd, TCIFLUSH);
|
||||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
tcsetattr(fd, TCSANOW, &options);
|
||||||
case WAIT_OBJECT_0:
|
|
||||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
return fd;
|
||||||
throwIOException(env, "Error waiting for write");
|
#else // __MINGW32__
|
||||||
}
|
const wchar_t * cportName = (const wchar_t *)(*env)->GetStringChars(env, portName, NULL);
|
||||||
}
|
HANDLE handle = CreateFile(cportName,
|
||||||
}
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
}
|
0,
|
||||||
|
NULL,
|
||||||
CloseHandle(olp.hEvent);
|
OPEN_EXISTING,
|
||||||
}
|
FILE_FLAG_OVERLAPPED,
|
||||||
|
NULL);
|
||||||
extern "C"
|
|
||||||
JNIEXPORT void JNICALL FUNC(write1)(JNIEnv *env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size)
|
if (handle == INVALID_HANDLE_VALUE) {
|
||||||
{
|
char msg[256];
|
||||||
OVERLAPPED olp = { 0 };
|
sprintf_s(msg, sizeof(msg), "Error opening %s", cportName);
|
||||||
|
throwIOException(env, msg);
|
||||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
return -1;
|
||||||
if (olp.hEvent == NULL) {
|
}
|
||||||
throwIOException(env, "Error creating event");
|
|
||||||
return;
|
DCB dcb = { 0 };
|
||||||
}
|
|
||||||
|
if (!GetCommState(handle, &dcb)) {
|
||||||
while (size > 0) {
|
throwIOException(env, "Error getting DCB");
|
||||||
char buff[256];
|
return -1;
|
||||||
DWORD nwritten = sizeof(buff) < size ? sizeof(buff) : size;
|
}
|
||||||
env->GetByteArrayRegion(bytes, offset, nwritten, (jbyte *)buff);
|
|
||||||
HANDLE handle = (HANDLE)jhandle;
|
dcb.BaudRate = baudRate;
|
||||||
|
dcb.ByteSize = (BYTE)byteSize;
|
||||||
if (!WriteFile(handle, buff, nwritten, &nwritten, &olp)) {
|
|
||||||
if (GetLastError() != ERROR_IO_PENDING) {
|
switch (parity) {
|
||||||
throwIOException(env, "Error writing to port");
|
case 0: // None
|
||||||
return;
|
dcb.fParity = FALSE;
|
||||||
}
|
break;
|
||||||
else {
|
case 1: // Even
|
||||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
dcb.fParity = TRUE;
|
||||||
case WAIT_OBJECT_0:
|
dcb.Parity = EVENPARITY;
|
||||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
break;
|
||||||
throwIOException(env, "Error waiting for write");
|
case 2: // Odd
|
||||||
return;
|
dcb.fParity = TRUE;
|
||||||
}
|
dcb.Parity = ODDPARITY;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
size -= nwritten;
|
switch (stopBits) {
|
||||||
offset += nwritten;
|
case 0:
|
||||||
}
|
dcb.StopBits = ONESTOPBIT;
|
||||||
|
break;
|
||||||
CloseHandle(olp.hEvent);
|
case 1:
|
||||||
}
|
dcb.StopBits = TWOSTOPBITS;
|
||||||
|
break;
|
||||||
extern "C"
|
}
|
||||||
JNIEXPORT jstring FUNC(getPortName)(JNIEnv *env, jclass cls, jint i)
|
|
||||||
{
|
if (!SetCommState(handle, &dcb)) {
|
||||||
HKEY key;
|
throwIOException(env, "Error setting DCB");
|
||||||
|
return -1;
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &key) != ERROR_SUCCESS) {
|
}
|
||||||
throwIOException(env, "Can not find registry key");
|
|
||||||
return NULL;
|
COMMTIMEOUTS timeouts = { 0 };
|
||||||
}
|
timeouts.ReadIntervalTimeout = MAXDWORD;
|
||||||
|
timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
|
||||||
wchar_t name[256];
|
timeouts.ReadTotalTimeoutConstant = 200;
|
||||||
DWORD len = sizeof(name);
|
if (!SetCommTimeouts(handle, &timeouts)) {
|
||||||
LONG rc = RegEnumValue(key, (DWORD)i, name, &len, NULL, NULL, NULL, NULL);
|
throwIOException(env, "Error setting timeouts");
|
||||||
if (rc != ERROR_SUCCESS) {
|
return -1;
|
||||||
if (rc != ERROR_NO_MORE_ITEMS) {
|
}
|
||||||
throwIOException(env, "Can not enum value");
|
|
||||||
}
|
#ifdef _WIN64
|
||||||
RegCloseKey(key);
|
return (jlong)handle;
|
||||||
return NULL;
|
#else
|
||||||
}
|
return (jlong)(unsigned)handle;
|
||||||
|
#endif
|
||||||
wchar_t value[256];
|
#endif // __MINGW32__
|
||||||
DWORD type;
|
}
|
||||||
len = sizeof(value);
|
|
||||||
if (RegQueryValueEx(key, name, NULL, &type, (BYTE *)value, &len) != ERROR_SUCCESS) {
|
JNIEXPORT void JNICALL FUNC(close0)(JNIEnv *env, jobject jobj, jlong handle)
|
||||||
throwIOException(env, "Can not query value");
|
{
|
||||||
RegCloseKey(key);
|
#ifndef __MINGW32__
|
||||||
return NULL;
|
close(handle);
|
||||||
}
|
#else
|
||||||
|
#ifdef _WIN64
|
||||||
jstring result = env->NewString((jchar *)value, (jsize) wcslen(value));
|
CloseHandle((HANDLE)handle);
|
||||||
RegCloseKey(key);
|
#else
|
||||||
return result;
|
CloseHandle((HANDLE)(unsigned)handle);
|
||||||
}
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL FUNC(read1)(JNIEnv * env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size)
|
||||||
|
{
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
jbyte buff[256];
|
||||||
|
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||||
|
n = read(jhandle, buff, n);
|
||||||
|
if (n > 0) {
|
||||||
|
(*env)->SetByteArrayRegion(env, bytes, offset, n, buff);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
#else
|
||||||
|
OVERLAPPED olp = { 0 };
|
||||||
|
|
||||||
|
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (olp.hEvent == NULL) {
|
||||||
|
throwIOException(env, "Error creating event");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buff[256];
|
||||||
|
DWORD nread = sizeof(buff) < size ? sizeof(buff) : size;
|
||||||
|
#ifdef _WIN64
|
||||||
|
HANDLE handle = (HANDLE)jhandle;
|
||||||
|
#else
|
||||||
|
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!ReadFile(handle, buff, sizeof(buff), &nread, &olp)) {
|
||||||
|
if (GetLastError() != ERROR_IO_PENDING) {
|
||||||
|
throwIOException(env, "Error reading from port");
|
||||||
|
CloseHandle(olp.hEvent);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
if (!GetOverlappedResult(handle, &olp, &nread, FALSE)) {
|
||||||
|
if (GetLastError() != ERROR_OPERATION_ABORTED) {
|
||||||
|
throwIOException(env, "Error waiting for read");
|
||||||
|
}
|
||||||
|
CloseHandle(olp.hEvent);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nread > 0) {
|
||||||
|
(*env)->SetByteArrayRegion(env, bytes, offset, nread, (jbyte *)buff);
|
||||||
|
}
|
||||||
|
CloseHandle(olp.hEvent);
|
||||||
|
return nread;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL FUNC(write0)(JNIEnv *env, jobject jobj, jlong jhandle, jint b)
|
||||||
|
{
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
char buff = b;
|
||||||
|
write(jhandle, &buff, 1);
|
||||||
|
#else
|
||||||
|
OVERLAPPED olp = { 0 };
|
||||||
|
|
||||||
|
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (olp.hEvent == NULL) {
|
||||||
|
throwIOException(env, "Error creating event");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buff = (char)b;
|
||||||
|
DWORD nwritten;
|
||||||
|
#ifdef _WIN64
|
||||||
|
HANDLE handle = (HANDLE)jhandle;
|
||||||
|
#else
|
||||||
|
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!WriteFile(handle, &buff, sizeof(buff), &nwritten, &olp)) {
|
||||||
|
if (GetLastError() != ERROR_IO_PENDING) {
|
||||||
|
throwIOException(env, "Error writing to port");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||||
|
throwIOException(env, "Error waiting for write");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(olp.hEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL FUNC(write1)(JNIEnv *env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size)
|
||||||
|
{
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
while (size > 0) {
|
||||||
|
jbyte buff[256];
|
||||||
|
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||||
|
(*env)->GetByteArrayRegion(env, bytes, offset, n, buff);
|
||||||
|
n = write(jhandle, buff, n);
|
||||||
|
if (n < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
size -= n;
|
||||||
|
offset += n;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
OVERLAPPED olp = { 0 };
|
||||||
|
|
||||||
|
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (olp.hEvent == NULL) {
|
||||||
|
throwIOException(env, "Error creating event");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (size > 0) {
|
||||||
|
char buff[256];
|
||||||
|
DWORD nwritten = sizeof(buff) < size ? sizeof(buff) : size;
|
||||||
|
(*env)->GetByteArrayRegion(env, bytes, offset, nwritten, (jbyte *)buff);
|
||||||
|
#ifdef _WIN64
|
||||||
|
HANDLE handle = (HANDLE)jhandle;
|
||||||
|
#else
|
||||||
|
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!WriteFile(handle, buff, nwritten, &nwritten, &olp)) {
|
||||||
|
if (GetLastError() != ERROR_IO_PENDING) {
|
||||||
|
throwIOException(env, "Error writing to port");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||||
|
throwIOException(env, "Error waiting for write");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size -= nwritten;
|
||||||
|
offset += nwritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(olp.hEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
JNIEXPORT jstring FUNC(getPortName)(JNIEnv *env, jclass cls, jint i)
|
||||||
|
{
|
||||||
|
HKEY key;
|
||||||
|
|
||||||
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &key) != ERROR_SUCCESS) {
|
||||||
|
throwIOException(env, "Can not find registry key");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t name[256];
|
||||||
|
DWORD len = sizeof(name);
|
||||||
|
LONG rc = RegEnumValue(key, (DWORD)i, name, &len, NULL, NULL, NULL, NULL);
|
||||||
|
if (rc != ERROR_SUCCESS) {
|
||||||
|
if (rc != ERROR_NO_MORE_ITEMS) {
|
||||||
|
throwIOException(env, "Can not enum value");
|
||||||
|
}
|
||||||
|
RegCloseKey(key);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t value[256];
|
||||||
|
DWORD type;
|
||||||
|
len = sizeof(value);
|
||||||
|
if (RegQueryValueEx(key, name, NULL, &type, (BYTE *)value, &len) != ERROR_SUCCESS) {
|
||||||
|
throwIOException(env, "Can not query value");
|
||||||
|
RegCloseKey(key);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jstring result = (*env)->NewString(env, (jchar *)value, (jsize) wcslen(value));
|
||||||
|
RegCloseKey(key);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,6 +0,0 @@
|
||||||
/ipch/
|
|
||||||
/Release/
|
|
||||||
/x64/
|
|
||||||
/serial.opensdf
|
|
||||||
/serial.sdf
|
|
||||||
/serial.v12.suo
|
|
|
@ -1,19 +0,0 @@
|
||||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
|
||||||
DWORD ul_reason_for_call,
|
|
||||||
LPVOID lpReserved
|
|
||||||
)
|
|
||||||
{
|
|
||||||
switch (ul_reason_for_call)
|
|
||||||
{
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2013
|
|
||||||
VisualStudioVersion = 12.0.31101.0
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serial", "serial.vcxproj", "{48ED88D3-77CF-4E77-9554-10719E633142}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{48ED88D3-77CF-4E77-9554-10719E633142}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
|
@ -1,176 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{48ED88D3-77CF-4E77-9554-10719E633142}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>serial</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)..\..\..\os\win32\x86\</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)..\..\..\os\win32\x86_64\</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SERIAL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SERIAL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SERIAL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include\win32;C:\Program Files\Java\jdk1.8.0_31\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SERIAL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include\win32;C:\Program Files\Java\jdk1.8.0_31\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Text Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="stdafx.h" />
|
|
||||||
<ClInclude Include="targetver.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="dllmain.cpp">
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="serial.cpp" />
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Text Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="targetver.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="serial.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="dllmain.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// serial.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
// TODO: reference any additional headers you need in STDAFX.H
|
|
||||||
// and not in this file
|
|
|
@ -1,17 +0,0 @@
|
||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "targetver.h"
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
// Windows Header Files:
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
#include <jni.h>
|
|
|
@ -1,8 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
|
||||||
|
|
||||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
|
||||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
|
||||||
|
|
||||||
#include <SDKDDKVer.h>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
native/org.eclipse.cdt.native.serial/os/win32/x86/serial.dll
Normal file → Executable file
BIN
native/org.eclipse.cdt.native.serial/os/win32/x86/serial.dll
Normal file → Executable file
Binary file not shown.
BIN
native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll
Normal file → Executable file
BIN
native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll
Normal file → Executable file
Binary file not shown.
Loading…
Add table
Reference in a new issue