aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2013-07-11 12:54:48 +0200
committerJakob Odersky <jodersky@gmail.com>2013-07-11 12:54:48 +0200
commit36ca3aac520cd64b0a50eab7a0049dbbaf800bb3 (patch)
tree6ca8a7a1ae4c6453bf17672125d65a1810964024
parent2059e7839fe529861656d1cff70ad33a4f26bf24 (diff)
parentc4a7228f3e8cdd5c5e34083811e4e3df8da4e637 (diff)
downloadakka-serial-36ca3aac520cd64b0a50eab7a0049dbbaf800bb3.tar.gz
akka-serial-36ca3aac520cd64b0a50eab7a0049dbbaf800bb3.tar.bz2
akka-serial-36ca3aac520cd64b0a50eab7a0049dbbaf800bb3.zip
Merge branch 'select'
-rw-r--r--README.md10
-rw-r--r--flow-binaries/linux/amd64/libflow.so.1.0bin13676 -> 13683 bytes
-rw-r--r--flow-binaries/linux/amd64/libflow.so.1.1bin0 -> 13734 bytes
-rw-r--r--flow-binaries/macosx/x86_64/libflow.jnilib.1.1bin0 -> 14360 bytes
-rw-r--r--flow-native/unix/src/flow.c26
-rw-r--r--project/Build.scala2
6 files changed, 22 insertions, 16 deletions
diff --git a/README.md b/README.md
index 7637667..d50b18f 100644
--- a/README.md
+++ b/README.md
@@ -19,9 +19,13 @@ Since flow integrates into the Akka-IO framework, a good resource on its general
### Currently supported platforms
-| OS | Architecture | Notes |
-|-------|--------------|--------------------------------------------------------------------|
-| Linux | amd64 | A user accessing a serial port needs to be in the 'dialout' group. |
+| OS (tested on) | Architecture | Notes |
+|-------------------|--------------|--------------------------------------------------------------------|
+| Linux (3.2.0) | x86_64 | A user accessing a serial port needs to be in the 'dialout' group. |
+|-------------------|--------------|--------------------------------------------------------------------|
+| Mac OS X (10.6.8) | x86_64 | - |
+
+Note: flow may work on older versions of the tested OS kernels.
## Build
diff --git a/flow-binaries/linux/amd64/libflow.so.1.0 b/flow-binaries/linux/amd64/libflow.so.1.0
index 9d0c6ed..8a02fed 100644
--- a/flow-binaries/linux/amd64/libflow.so.1.0
+++ b/flow-binaries/linux/amd64/libflow.so.1.0
Binary files differ
diff --git a/flow-binaries/linux/amd64/libflow.so.1.1 b/flow-binaries/linux/amd64/libflow.so.1.1
new file mode 100644
index 0000000..ed82d57
--- /dev/null
+++ b/flow-binaries/linux/amd64/libflow.so.1.1
Binary files differ
diff --git a/flow-binaries/macosx/x86_64/libflow.jnilib.1.1 b/flow-binaries/macosx/x86_64/libflow.jnilib.1.1
new file mode 100644
index 0000000..76961f0
--- /dev/null
+++ b/flow-binaries/macosx/x86_64/libflow.jnilib.1.1
Binary files differ
diff --git a/flow-native/unix/src/flow.c b/flow-native/unix/src/flow.c
index 97e8e23..29769d3 100644
--- a/flow-native/unix/src/flow.c
+++ b/flow-native/unix/src/flow.c
@@ -35,7 +35,6 @@
#include <errno.h>
#include <termios.h>
#include <fcntl.h>
-#include <poll.h>
#include "com_github_jodersky_flow_internal_NativeSerial.h"
#include "flow.h"
@@ -187,22 +186,25 @@ int serial_close(struct serial_config* serial) {
}
int serial_read(struct serial_config* serial, unsigned char* buffer, size_t size) {
+ int port = serial->port_fd;
+ int pipe = serial->pipe_read_fd;
- struct pollfd polls[2];
- polls[0].fd = serial->port_fd; // serial poll
- polls[0].events = POLLIN;
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(port, &rfds);
+ FD_SET(pipe, &rfds);
- polls[1].fd = serial->pipe_read_fd; // pipe poll
- polls[1].events = POLLIN;
+ int nfds = pipe + 1;
+ if (pipe < port) nfds = port + 1;
- int n = poll(polls,2,-1);
+ int n = select(nfds, &rfds, NULL, NULL, NULL);
if (n < 0) {
- DEBUG(perror("poll"););
+ DEBUG(perror("select"););
return E_IO;
}
- if ((polls[0].revents & POLLIN) != 0) {
- int r = read(polls[0].fd, buffer, size);
+ if (FD_ISSET(port, &rfds)) {
+ int r = read(port, buffer, size);
//treat 0 bytes read as an error to avoid problems on disconnect
//anyway, after a poll there should be more than 0 bytes available to read
@@ -211,10 +213,10 @@ int serial_read(struct serial_config* serial, unsigned char* buffer, size_t size
return E_IO;
}
return r;
- } else if ((polls[1].revents & POLLIN) != 0) {
+ } else if (FD_ISSET(pipe, &rfds)) {
return E_INTERRUPT;
} else {
- fprintf(stderr, "poll revents: unknown revents\nserial: %d\npipe: %d", polls[0].revents, polls[1].revents);
+ fputs("select: unknown read sets", stderr);
return E_IO;
}
}
diff --git a/project/Build.scala b/project/Build.scala
index 8b84c5b..7bd5196 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -106,7 +106,7 @@ val binaries: Seq[(File, File)] = getLatestBinaries(binDir, BinaryMajorVersion)
//--- native unix-like settings ----------------------------------------
- val UnixBinaryMinorVersion = 0
+ val UnixBinaryMinorVersion = 1
lazy val unixNativeSettings: Seq[Setting[_]] = commonNativeSettings ++ Seq(
flags in Native := Seq("-fPIC", "-O2")