diff --git a/.classpath b/.classpath index a48ae7b..6e022d9 100644 --- a/.classpath +++ b/.classpath @@ -5,7 +5,7 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7341ab1..3a21537 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ 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.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/src/native/linux32/libnsp.so b/src/native/linux32/libnsp.so index 46ccbd6..a232f50 100755 Binary files a/src/native/linux32/libnsp.so and b/src/native/linux32/libnsp.so differ diff --git a/src/native/linux64/libnsp.so b/src/native/linux64/libnsp.so index e5c0634..df1fc16 100755 Binary files a/src/native/linux64/libnsp.so and b/src/native/linux64/libnsp.so differ diff --git a/src/native/mswin32/nsp.dll b/src/native/mswin32/nsp.dll index 75e10f2..02a3603 100755 Binary files a/src/native/mswin32/nsp.dll and b/src/native/mswin32/nsp.dll differ diff --git a/src/native/mswin64/nsp.dll b/src/native/mswin64/nsp.dll index 23f2f23..e9f8f53 100644 Binary files a/src/native/mswin64/nsp.dll and b/src/native/mswin64/nsp.dll differ diff --git a/src/native/osx32/libnsp.dylib b/src/native/osx32/libnsp.dylib index 32cfce6..fd2eb24 100755 Binary files a/src/native/osx32/libnsp.dylib and b/src/native/osx32/libnsp.dylib differ diff --git a/src/native/osx64/libnsp.dylib b/src/native/osx64/libnsp.dylib index 32cfce6..fd2eb24 100755 Binary files a/src/native/osx64/libnsp.dylib and b/src/native/osx64/libnsp.dylib differ diff --git a/src/org/hwo/io/NewSerialPort/NewSerialPort.java b/src/org/hwo/io/NewSerialPort/NewSerialPort.java index dcbcb78..74af703 100644 --- a/src/org/hwo/io/NewSerialPort/NewSerialPort.java +++ b/src/org/hwo/io/NewSerialPort/NewSerialPort.java @@ -30,6 +30,7 @@ public class NewSerialPort { public static long nsp_RET_OTHER = -99; // Unbekannter Fehler + public static long EAGAIN; String portName; int baudRate; @@ -164,6 +165,7 @@ public class NewSerialPort { } public void setTimeOut(int timeout){ this.timeout = timeout; + log(DEBUG,"NSP: setTimeOut( %d )",timeout); nsp_setup_timeout(nsp, timeout); } @@ -264,20 +266,22 @@ public class NewSerialPort { private static native int nsp_read_bytes(long nsp,byte[] bytes,int offset,int len); private static native int nsp_write_bytes(long nsp,byte[] bytes,int offset,int len); - + private static native int nsp_EAGAIN(); static { NativeLoader.loadLibrary("nsp"); - } - - + + EAGAIN = nsp_EAGAIN(); + } public class NewSerialPortInputStream extends InputStream { @Override public int read() throws IOException { if (autoOpen && !isOpen()) open(); - + + log(DEBUGDETAIL,"NSP::read()"); + int ch = nsp_read(nsp); if (ch < 0){ if (ch == nsp_RET_TIMEOUT) @@ -299,9 +303,11 @@ public class NewSerialPort { @Override public int read(byte[] b, int off, int len) throws IOException { + //log(DEBUGDETAIL,"NSP::read()"); + int nRead = nsp_read_bytes(nsp, b, off, len); if (nRead < 0){ - if (nRead == -11){ // -EAGAIN (timeout, keine zeichen verfügbar) + if (nRead == EAGAIN){ // -EAGAIN (timeout, keine zeichen verfügbar) return 0; }; throw new IOException(String.format("nsp_read_bytes() returned %d", nRead)); @@ -359,10 +365,13 @@ public class NewSerialPort { public void write(byte[] b, int off, int len) throws IOException { int nWritten = 0; - for (int redo=0;redo<5;redo++){ + log(DEBUGDETAIL,"NSP::write(...)"); + + for (int redo=0; redo < 5 ; redo++){ nWritten = nsp_write_bytes(nsp, b, off, len); - if (nWritten == -11){ + if (nWritten == EAGAIN){ try { + log(DEBUGDETAIL,"SL-TX-EAGAIN... [%d]",redo); Thread.sleep(5); } catch (Exception e){ @@ -405,10 +414,10 @@ public class NewSerialPort { for (int i = 1; i < 32; i++) { - sp.setPortName(String.format("COM%d:",i)); + sp.setPortName(String.format("COM%d",i)); if (sp.open()) { - portNames.add(String.format("COM%d:",i)); + portNames.add(String.format("COM%d",i)); sp.close(); } }