From dd264239a59290b37e947afd437dd1bf654c9196 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Thu, 11 Jul 2013 11:40:38 +0200 Subject: use select system call instead of poll (because mac doesn't support poll on devices) --- flow-binaries/linux/amd64/libflow.so.1.0 | Bin 13676 -> 13683 bytes flow-binaries/linux/amd64/libflow.so.1.1 | Bin 0 -> 13734 bytes flow-native/unix/src/flow.c | 26 ++++++++++++++------------ project/Build.scala | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 flow-binaries/linux/amd64/libflow.so.1.1 diff --git a/flow-binaries/linux/amd64/libflow.so.1.0 b/flow-binaries/linux/amd64/libflow.so.1.0 index 9d0c6ed..8a02fed 100644 Binary files a/flow-binaries/linux/amd64/libflow.so.1.0 and b/flow-binaries/linux/amd64/libflow.so.1.0 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 Binary files /dev/null and b/flow-binaries/linux/amd64/libflow.so.1.1 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 #include #include -#include #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") -- cgit v1.2.3 From 01e765d8a6149f759814a5114f567ffa83818146 Mon Sep 17 00:00:00 2001 From: jodersky Date: Thu, 11 Jul 2013 12:29:05 +0200 Subject: add binary compiled under Mac OSX 10.6.8 --- flow-binaries/macosx/x86_64/libflow.jnilib.1.1 | Bin 0 -> 14360 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 flow-binaries/macosx/x86_64/libflow.jnilib.1.1 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 Binary files /dev/null and b/flow-binaries/macosx/x86_64/libflow.jnilib.1.1 differ -- cgit v1.2.3 From c4a7228f3e8cdd5c5e34083811e4e3df8da4e637 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Thu, 11 Jul 2013 12:54:35 +0200 Subject: update README to support macosx --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b3ffe4a..c13ac82 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 -- cgit v1.2.3