diff options
author | Jakob Odersky <jodersky@gmail.com> | 2013-06-18 19:40:22 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2013-06-18 19:40:22 +0200 |
commit | 98241aa830bedb006ae041dce661afd57c3d90a8 (patch) | |
tree | 70443e7597aca759733e587220a8323fde89af1f /src/main/java | |
parent | b0c32f5325702dd7f7ef3d5ccc0eb9a2b972cf7a (diff) | |
download | akka-serial-98241aa830bedb006ae041dce661afd57c3d90a8.tar.gz akka-serial-98241aa830bedb006ae041dce661afd57c3d90a8.tar.bz2 akka-serial-98241aa830bedb006ae041dce661afd57c3d90a8.zip |
use sbt-native plugin and restructure build
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/github/jodersky/flow/low/NativeSerial.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/com/github/jodersky/flow/low/NativeSerial.java b/src/main/java/com/github/jodersky/flow/low/NativeSerial.java new file mode 100644 index 0000000..6bdcde5 --- /dev/null +++ b/src/main/java/com/github/jodersky/flow/low/NativeSerial.java @@ -0,0 +1,49 @@ +package com.github.jodersky.flow.low; + +class NativeSerial { + + static { + NativeLoader.load(); + } + + 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); + +} |