aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2013-05-21 13:41:49 +0200
committerJakob Odersky <jodersky@gmail.com>2013-05-21 13:41:49 +0200
commit507e3a235ca5e7e62e105fd46df7186e8559ac98 (patch)
tree873eeab88f81427a27d5501dc9c74084b88b223c /src/main/java/com
downloadakka-serial-507e3a235ca5e7e62e105fd46df7186e8559ac98.tar.gz
akka-serial-507e3a235ca5e7e62e105fd46df7186e8559ac98.tar.bz2
akka-serial-507e3a235ca5e7e62e105fd46df7186e8559ac98.zip
initial commit
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/jodersky/flow/NativeSerial.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/com/github/jodersky/flow/NativeSerial.java b/src/main/java/com/github/jodersky/flow/NativeSerial.java
new file mode 100644
index 0000000..10a82c9
--- /dev/null
+++ b/src/main/java/com/github/jodersky/flow/NativeSerial.java
@@ -0,0 +1,49 @@
+package com.github.jodersky.flow;
+
+public class NativeSerial {
+
+ static {
+ System.loadLibrary("flow");
+ }
+
+ final static int E_PERMISSION = -1;
+ final static int E_OPEN = -2;
+ final static int E_BUSY = -3;
+ final static int E_BAUD = -4;
+ final static int E_PIPE = -5;
+ final static int E_MALLOC = -6;
+ final static int E_POINTER = -7;
+ final static int E_POLL = -8;
+ final static int E_IO = -9;
+ final static int E_CLOSE = -10;
+
+
+ /* return values:
+ * 0 ok
+ * E_PERMISSION don't have permission to open
+ * E_OPEN can't get file descriptor
+ * E_BUSY device busy
+ * E_BAUD invalid baudrate
+ * E_PIPE can't open pipe for graceful closing
+ * E_MALLOC malloc error */
+ native static int open(String device, int baud, long[] serial);
+
+ /* return
+ * >0 number of bytes read
+ * E_POINTER invalid serial pointer
+ * E_POLL poll error
+ * E_IO read error
+ * E_CLOSE close request */
+ native static int read(long serial, byte[] buffer);
+
+ /*return
+ * >0 number of bytes written
+ * E_POINTER invalid serial config (null pointer)
+ * E_IO write error */
+ native static int write(long serial, byte[] buffer);
+
+ native static void close(long serial);
+
+ native static void debug(boolean value);
+
+}