aboutsummaryrefslogtreecommitdiff
path: root/flow-native/src
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-04-17 11:10:20 +0200
committerJakob Odersky <jodersky@gmail.com>2014-04-17 11:10:20 +0200
commitc8b37629844c4ca3ec9c9e54b7e54775201d75fc (patch)
tree0cddcbf7fda72310a94340abbb16afb69a9a03ed /flow-native/src
parentd5affc83535f8acc1119be6d05b834a11d059f88 (diff)
downloadakka-serial-c8b37629844c4ca3ec9c9e54b7e54775201d75fc.tar.gz
akka-serial-c8b37629844c4ca3ec9c9e54b7e54775201d75fc.tar.bz2
akka-serial-c8b37629844c4ca3ec9c9e54b7e54775201d75fc.zip
update build
Diffstat (limited to 'flow-native/src')
-rw-r--r--flow-native/src/Makefile.am3
-rw-r--r--flow-native/src/Makefile.in535
-rw-r--r--flow-native/src/com_github_jodersky_flow_internal_NativeSerial.h83
-rw-r--r--flow-native/src/flow.h90
-rw-r--r--flow-native/src/flow_jni.c169
-rw-r--r--flow-native/src/platform/posix/flow.c248
-rw-r--r--flow-native/src/platform/windows/README1
-rw-r--r--flow-native/src/platform/windows/flow.c.disabled416
8 files changed, 1545 insertions, 0 deletions
diff --git a/flow-native/src/Makefile.am b/flow-native/src/Makefile.am
new file mode 100644
index 0000000..a002cea
--- /dev/null
+++ b/flow-native/src/Makefile.am
@@ -0,0 +1,3 @@
+lib_LTLIBRARIES = libflow.la
+
+libflow_la_SOURCES = flow_jni.c platform/posix/flow.c flow.h com_github_jodersky_flow_internal_NativeSerial.h \ No newline at end of file
diff --git a/flow-native/src/Makefile.in b/flow-native/src/Makefile.in
new file mode 100644
index 0000000..7990789
--- /dev/null
+++ b/flow-native/src/Makefile.in
@@ -0,0 +1,535 @@
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(libdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libflow_la_LIBADD =
+am_libflow_la_OBJECTS = flow_jni.lo flow.lo
+libflow_la_OBJECTS = $(am_libflow_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libflow_la_SOURCES)
+DIST_SOURCES = $(libflow_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+lib_LTLIBRARIES = libflow.la
+libflow_la_SOURCES = flow_jni.c platform/posix/flow.c flow.h com_github_jodersky_flow_internal_NativeSerial.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libflow.la: $(libflow_la_OBJECTS) $(libflow_la_DEPENDENCIES) $(EXTRA_libflow_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libflow_la_OBJECTS) $(libflow_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_jni.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+flow.lo: platform/posix/flow.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT flow.lo -MD -MP -MF $(DEPDIR)/flow.Tpo -c -o flow.lo `test -f 'platform/posix/flow.c' || echo '$(srcdir)/'`platform/posix/flow.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/flow.Tpo $(DEPDIR)/flow.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='platform/posix/flow.c' object='flow.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o flow.lo `test -f 'platform/posix/flow.c' || echo '$(srcdir)/'`platform/posix/flow.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-libLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/flow-native/src/com_github_jodersky_flow_internal_NativeSerial.h b/flow-native/src/com_github_jodersky_flow_internal_NativeSerial.h
new file mode 100644
index 0000000..04364fb
--- /dev/null
+++ b/flow-native/src/com_github_jodersky_flow_internal_NativeSerial.h
@@ -0,0 +1,83 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_github_jodersky_flow_internal_NativeSerial */
+
+#ifndef _Included_com_github_jodersky_flow_internal_NativeSerial
+#define _Included_com_github_jodersky_flow_internal_NativeSerial
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_github_jodersky_flow_internal_NativeSerial_PARITY_NONE
+#define com_github_jodersky_flow_internal_NativeSerial_PARITY_NONE 0L
+#undef com_github_jodersky_flow_internal_NativeSerial_PARITY_ODD
+#define com_github_jodersky_flow_internal_NativeSerial_PARITY_ODD 1L
+#undef com_github_jodersky_flow_internal_NativeSerial_PARITY_EVEN
+#define com_github_jodersky_flow_internal_NativeSerial_PARITY_EVEN 2L
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: open
+ * Signature: (Ljava/lang/String;IIZI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_open
+ (JNIEnv *, jclass, jstring, jint, jint, jboolean, jint);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: readDirect
+ * Signature: (JLjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_readDirect
+ (JNIEnv *, jclass, jlong, jobject);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: read
+ * Signature: (J[B)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_read
+ (JNIEnv *, jclass, jlong, jbyteArray);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: cancelRead
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_cancelRead
+ (JNIEnv *, jclass, jlong);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: writeDirect
+ * Signature: (JLjava/nio/ByteBuffer;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_writeDirect
+ (JNIEnv *, jclass, jlong, jobject, jint);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: write
+ * Signature: (J[BI)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_write
+ (JNIEnv *, jclass, jlong, jbyteArray, jint);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: close
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_close
+ (JNIEnv *, jclass, jlong);
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: debug
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_debug
+ (JNIEnv *, jclass, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/flow-native/src/flow.h b/flow-native/src/flow.h
new file mode 100644
index 0000000..ff80259
--- /dev/null
+++ b/flow-native/src/flow.h
@@ -0,0 +1,90 @@
+#ifndef FLOW_H
+#define FLOW_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+//general error codes that are returned by functions
+#define E_IO -1 //IO error
+#define E_ACCESS_DENIED -2 //access denied
+#define E_BUSY -3 // port is busy
+#define E_INVALID_SETTINGS -4 // some port settings are invalid
+#define E_INTERRUPT -5 // not really an error, function call aborted because port is closed
+#define E_NO_PORT -6 //requested port does not exist
+
+#define PARITY_NONE 0
+#define PARITY_ODD 1
+#define PARITY_EVEN 2
+
+/** Contains internal configuration of an open serial port. */
+struct serial_config;
+
+/**Opens a serial port and allocates memory for storing configuration. Note: if this function fails,
+ * any internally allocated resources will be freed.
+ * @param port_name name of port
+ * @param baud baud rate
+ * @param char_size character size of data transmitted through serial device
+ * @param two_stop_bits set to use two stop bits instead of one
+ * @param parity kind of parity checking to use
+ * @param serial pointer to memory that will be allocated with a serial structure
+ * @return 0 on success
+ * @return E_NO_PORT if the given port does not exist
+ * @return E_ACCESS_DENIED if permissions are not sufficient to open port
+ * @return E_BUSY if port is already in use
+ * @return E_INVALID_SETTINGS if any of the specified settings are invalid
+ * @return E_IO on other error */
+int serial_open(
+ const char* port_name,
+ int baud,
+ int char_size,
+ bool two_stop_bits,
+ int parity,
+ struct serial_config** const serial);
+
+/**Closes a previously opened serial port and frees memory containing the configuration. Note: after a call to
+ * this function, the 'serial' pointer will become invalid, make sure you only call it once. This function is NOT
+ * thread safe, make sure no read or write is in prgress when this function is called (the reason is that per
+ * close manual page, close should not be called on a file descriptor that is in use by another thread).
+ * @param serial pointer to serial configuration that is to be closed (and freed)
+ * @return 0 on success
+ * @return E_IO on error */
+int serial_close(struct serial_config* const serial);
+
+/**Starts a read from a previously opened serial port. The read is blocking, however it may be
+ * interrupted by calling 'serial_cancel_read' on the given serial port.
+ * @param serial pointer to serial configuration from which to read
+ * @param buffer buffer into which data is read
+ * @param size maximum buffer size
+ * @return n>0 the number of bytes read into buffer
+ * @return E_INTERRUPT if the call to this function was interrupted
+ * @return E_IO on IO error */
+int serial_read(struct serial_config* const serial, char* const buffer, size_t size);
+
+/**Cancels a blocked read call. This function is thread safe, i.e. it may be called from a thread even
+ * while another thread is blocked in a read call.
+ * @param serial_config the serial port to interrupt
+ * @return 0 on success
+ * @return E_IO on error */
+int serial_cancel_read(struct serial_config* const serial);
+
+/**Writes data to a previously opened serial port. Non bocking.
+ * @param serial pointer to serial configuration to which to write
+ * @param data data to write
+ * @param size number of bytes to write from data
+ * @return n>0 the number of bytes written
+ * @return E_IO on IO error */
+int serial_write(struct serial_config* const serial, char* const data, size_t size);
+
+/**Sets debugging option. If debugging is enabled, detailed error message are printed from method calls. */
+void serial_debug(bool value);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* FLOW_H */
diff --git a/flow-native/src/flow_jni.c b/flow-native/src/flow_jni.c
new file mode 100644
index 0000000..8ec2aed
--- /dev/null
+++ b/flow-native/src/flow_jni.c
@@ -0,0 +1,169 @@
+#include "flow.h"
+#include "com_github_jodersky_flow_internal_NativeSerial.h"
+
+
+static inline void throwException(JNIEnv* env, const char* const exception, const char * const message) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, exception), message);
+}
+
+static inline void check(JNIEnv* env, int id) {
+ switch (id) {
+ case E_IO: throwException(env, "java/io/IOException", ""); break;
+ case E_BUSY: throwException(env, "com/github/jodersky/flow/PortInUseException", ""); break;
+ case E_ACCESS_DENIED: throwException(env, "com/github/jodersky/flow/AccessDeniedException", ""); break;
+ case E_INVALID_SETTINGS: throwException(env, "com/github/jodersky/flow/InvalidSettingsException", ""); break;
+ case E_INTERRUPT: throwException(env, "com/github/jodersky/flow/PortInterruptedException", ""); break;
+ case E_NO_PORT: throwException(env, "com/github/jodersky/flow/NoSuchPortException", ""); break;
+ default: return;
+ }
+}
+
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: open
+ * Signature: (Ljava/lang/String;IIZI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_open
+ (JNIEnv *env, jclass clazz, jstring port_name, jint baud, jint char_size, jboolean two_stop_bits, jint parity) {
+
+ const char *dev = (*env)->GetStringUTFChars(env, port_name, 0);
+ struct serial_config* config;
+ int r = serial_open(dev, baud, char_size, two_stop_bits, parity, &config);
+ (*env)->ReleaseStringUTFChars(env, port_name, dev);
+
+
+ if (r < 0) {
+ check(env, r);
+ return 0;
+ }
+
+ long jpointer = (long) config;
+ return jpointer;
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: readDirect
+ * Signature: (JLjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_readDirect
+ (JNIEnv *env, jclass clazz, jlong config, jobject buffer) {
+
+ char* local_buffer = (char*) (*env)->GetDirectBufferAddress(env, buffer);
+ if (local_buffer == NULL) {
+ throwException(env, "java/lang/IllegalArgumentException", "ByteBuffer not direct");
+ return -1;
+ }
+ jlong size = (*env)->GetDirectBufferCapacity(env, buffer);
+
+ int r = serial_read((struct serial_config*) config, local_buffer, (size_t) size);
+ if (r < 0) {
+ check(env, r);
+ return -1;
+ }
+ return r;
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: read
+ * Signature: (J[B)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_read
+ (JNIEnv *env, jclass clazz, jlong config, jbyteArray buffer) {
+
+ jsize size = (*env)->GetArrayLength(env, buffer);
+ char local_buffer[size];
+ int r = serial_read((struct serial_config*) config, local_buffer, size);
+ if (r < 0) {
+ check(env, r);
+ return -1;
+ }
+
+ (*env)->SetByteArrayRegion(env, buffer, 0, r, (signed char *) local_buffer);
+ return r;
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: cancelRead
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_cancelRead
+ (JNIEnv *env, jclass clazz, jlong config) {
+
+ int r = serial_cancel_read((struct serial_config*) config);
+ if (r < 0) {
+ check(env, r);
+ }
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: writeDirect
+ * Signature: (JLjava/nio/ByteBuffer;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_writeDirect
+ (JNIEnv *env, jclass clazz, jlong config, jobject buffer, jint size) {
+
+ char* local_buffer = (char *) (*env)->GetDirectBufferAddress(env, buffer);
+ if (local_buffer == NULL) {
+ throwException(env, "java/lang/IllegalArgumentException", "ByteBuffer not direct");
+ return -1;
+ }
+
+ int r = serial_write((struct serial_config*) config, local_buffer, (size_t) size);
+ if (r < 0) {
+ check(env, r);
+ return -1;
+ }
+ return r;
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: write
+ * Signature: (J[BI)I
+ */
+JNIEXPORT jint JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_write
+ (JNIEnv *env, jclass clazz, jlong config, jbyteArray buffer, jint size) {
+
+ char* local_buffer = (char*) (*env)->GetByteArrayElements(env, buffer, NULL);
+ int r = serial_write((struct serial_config*) config, local_buffer, size);
+ (*env)->ReleaseByteArrayElements(env, buffer, (signed char*) local_buffer, JNI_ABORT);
+ if (r < 0) {
+ check(env, r);
+ return -1;
+ }
+ return r;
+
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: close
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_close
+ (JNIEnv *env, jclass clazz, jlong config) {
+ int r = serial_close((struct serial_config*) config);
+ if (r < 0) {
+ check(env, r);
+ }
+}
+
+/*
+ * Class: com_github_jodersky_flow_internal_NativeSerial
+ * Method: debug
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_github_jodersky_flow_internal_NativeSerial_debug
+ (JNIEnv *env, jclass clazz, jboolean value) {
+ serial_debug((bool) value);
+} \ No newline at end of file
diff --git a/flow-native/src/platform/posix/flow.c b/flow-native/src/platform/posix/flow.c
new file mode 100644
index 0000000..1adb10c
--- /dev/null
+++ b/flow-native/src/platform/posix/flow.c
@@ -0,0 +1,248 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/file.h>
+#include "flow.h"
+
+
+#define DATA_CANCEL 0xffffffff
+
+static bool debug = false;
+#define DEBUG(f) if (debug) {f}
+
+void serial_debug(bool value) {
+ debug = value;
+}
+
+//contains file descriptors used in managing a serial port
+struct serial_config {
+ int port_fd; // file descriptor of serial port
+
+ /* a pipe is used to abort a serial read by writing something into the
+ * write end of the pipe */
+ int pipe_read_fd; // file descriptor, read end of pipe
+ int pipe_write_fd; // file descriptor, write end of pipe
+};
+
+int serial_open(
+ const char* const port_name,
+ int baud,
+ int char_size,
+ bool two_stop_bits,
+ int parity,
+ struct serial_config** serial) {
+
+ int fd = open(port_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
+
+ if (fd < 0) {
+ int en = errno;
+ DEBUG(perror("error obtaining port file descriptor"););
+ if (en == EACCES) return E_ACCESS_DENIED;
+ if (en == ENOENT) return E_NO_PORT;
+ return E_IO;
+ }
+
+ if (flock(fd, LOCK_EX | LOCK_NB) < 0) {
+ DEBUG(perror("error acquiring lock on port"););
+ close(fd);
+ return E_BUSY;
+ }
+
+ /* configure new port settings */
+ struct termios newtio;
+
+ /* following calls correspond to makeraw() */
+ newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
+ newtio.c_oflag &= ~OPOST;
+ newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ newtio.c_cflag &= ~(CSIZE | PARENB);
+ newtio.c_cflag |= CREAD;
+
+ /* set speed */
+ speed_t bd;
+ switch (baud) {
+ case 50: bd = B50; break;
+ case 75: bd = B75; break;
+ case 110: bd = B110; break;
+ case 134: bd = B134; break;
+ case 150: bd = B150; break;
+ case 200: bd = B200; break;
+ case 300: bd = B300; break;
+ case 600: bd = B600; break;
+ case 1200: bd = B1200; break;
+ case 1800: bd = B1800; break;
+ case 2400: bd = B2400; break;
+ case 4800: bd = B4800; break;
+ case 9600: bd = B9600; break;
+ case 19200: bd = B19200; break;
+ case 38400: bd = B38400; break;
+ case 57600: bd = B57600; break;
+ case 115200: bd = B115200; break;
+ case 230400: bd = B230400; break;
+ default:
+ close(fd);
+ DEBUG(fprintf(stderr, "invalid baud rate %d\n", baud););
+ return E_INVALID_SETTINGS;
+ }
+
+ if (cfsetspeed(&newtio, bd) < 0) {
+ DEBUG(perror("error setting baud rate"););
+ close(fd);
+ return E_IO;
+ }
+
+ /* set char size*/
+ switch (char_size) {
+ case 5: newtio.c_cflag |= CS5; break;
+ case 6: newtio.c_cflag |= CS6; break;
+ case 7: newtio.c_cflag |= CS7; break;
+ case 8: newtio.c_cflag |= CS8; break;
+ default:
+ close(fd);
+ DEBUG(fprintf(stderr, "invalid character size %d\n", char_size););
+ return E_INVALID_SETTINGS;
+ }
+
+ /* use two stop bits */
+ if (two_stop_bits){
+ newtio.c_cflag |= CSTOPB;
+ }
+
+ /* set parity */
+ switch (parity) {
+ case PARITY_NONE: break;
+ case PARITY_ODD: newtio.c_cflag |= (PARENB | PARODD); break;
+ case PARITY_EVEN: newtio.c_cflag |= PARENB; break;
+ default:
+ close(fd);
+ DEBUG(fprintf(stderr, "invalid parity %d\n", parity););
+ return E_INVALID_SETTINGS;
+ }
+
+ if (tcflush(fd, TCIOFLUSH) < 0) {
+ DEBUG(perror("error flushing serial settings"););
+ close(fd);
+ return E_IO;
+ }
+
+ if (tcsetattr(fd, TCSANOW, &newtio) < 0) {
+ DEBUG(perror("error applying serial settings"););
+ close(fd);
+ return E_IO;
+ }
+
+ int pipe_fd[2];
+ if (pipe(pipe_fd) < 0) {
+ DEBUG(perror("error opening pipe"););
+ close(fd);
+ return E_IO;
+ }
+
+ if (fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK) < 0 || fcntl(pipe_fd[1], F_SETFL, O_NONBLOCK) < 0) {
+ DEBUG(perror("error setting pipe to non-blocking"););
+ close(fd);
+ close(pipe_fd[0]);
+ close(pipe_fd[1]);
+ return E_IO;
+ }
+
+ struct serial_config* s = malloc(sizeof(s));
+ if (s == NULL) {
+ DEBUG(perror("error allocating memory for serial configuration"););
+ close(fd);
+ close(pipe_fd[0]);
+ close(pipe_fd[1]);
+ return E_IO;
+ }
+
+ s->port_fd = fd;
+ s->pipe_read_fd = pipe_fd[0];
+ s->pipe_write_fd = pipe_fd[1];
+ (*serial) = s;
+
+ return 0;
+}
+
+
+int serial_close(struct serial_config* const serial) {
+ if (close(serial->pipe_write_fd) < 0) {
+ DEBUG(perror("error closing write end of pipe"););
+ return E_IO;
+ }
+ if (close(serial->pipe_read_fd) < 0) {
+ DEBUG(perror("error closing read end of pipe"););
+ return E_IO;
+ }
+
+ if (flock(serial->port_fd, LOCK_UN) < 0){
+ DEBUG(perror("error releasing lock on port"););
+ return E_IO;
+ }
+ if (close(serial->port_fd) < 0) {
+ DEBUG(perror("error closing port"););
+ return E_IO;
+ }
+
+ free(serial);
+ return 0;
+}
+
+int serial_read(struct serial_config* const serial, char* const buffer, size_t size) {
+ int port = serial->port_fd;
+ int pipe = serial->pipe_read_fd;
+
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(port, &rfds);
+ FD_SET(pipe, &rfds);
+
+ int nfds = pipe + 1;
+ if (pipe < port) nfds = port + 1;
+
+ int n = select(nfds, &rfds, NULL, NULL, NULL);
+ if (n < 0) {
+ DEBUG(perror("error trying to call select on port and pipe"););
+ return E_IO;
+ }
+
+ if (FD_ISSET(pipe, &rfds)) {
+ return E_INTERRUPT;
+ } else 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
+ if (r <= 0) {
+ DEBUG(perror("error data not available after select"););
+ return E_IO;
+ }
+ return r;
+ } else {
+ fprintf(stderr, "select returned unknown read sets\n");
+ return E_IO;
+ }
+}
+
+int serial_cancel_read(struct serial_config* const serial) {
+ int data = DATA_CANCEL;
+
+ //write to pipe to wake up any blocked read thread (self-pipe trick)
+ if (write(serial->pipe_write_fd, &data, 1) < 0) {
+ DEBUG(perror("error writing to pipe during read cancel"););
+ return E_IO;
+ }
+
+ return 0;
+}
+
+int serial_write(struct serial_config* const serial, char* const data, size_t size) {
+ int r = write(serial->port_fd, data, size);
+ if (r < 0) {
+ DEBUG(perror("error writing to port"););
+ return E_IO;
+ }
+ return r;
+} \ No newline at end of file
diff --git a/flow-native/src/platform/windows/README b/flow-native/src/platform/windows/README
new file mode 100644
index 0000000..3d24410
--- /dev/null
+++ b/flow-native/src/platform/windows/README
@@ -0,0 +1 @@
+The contents of the file flow.c were found in the avrdude project. They look like they may be a good starting point for serial communication on windows.
diff --git a/flow-native/src/platform/windows/flow.c.disabled b/flow-native/src/platform/windows/flow.c.disabled
new file mode 100644
index 0000000..86a267c
--- /dev/null
+++ b/flow-native/src/platform/windows/flow.c.disabled
@@ -0,0 +1,416 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de>
+ * Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* $Id$ */
+
+/*
+ * Native Win32 serial interface for avrdude.
+ */
+
+#include "avrdude.h"
+
+#if defined(WIN32NATIVE)
+
+#include <windows.h>
+#include <stdio.h>
+#include <ctype.h> /* for isprint */
+
+#include "serial.h"
+
+long serial_recv_timeout = 5000; /* ms */
+
+#define W32SERBUFSIZE 1024
+
+struct baud_mapping {
+ long baud;
+ DWORD speed;
+};
+
+/* HANDLE hComPort=INVALID_HANDLE_VALUE; */
+
+static struct baud_mapping baud_lookup_table [] = {
+ { 1200, CBR_1200 },
+ { 2400, CBR_2400 },
+ { 4800, CBR_4800 },
+ { 9600, CBR_9600 },
+ { 19200, CBR_19200 },
+ { 38400, CBR_38400 },
+ { 57600, CBR_57600 },
+ { 115200, CBR_115200 },
+ { 0, 0 } /* Terminator. */
+};
+
+static DWORD serial_baud_lookup(long baud)
+{
+ struct baud_mapping *map = baud_lookup_table;
+
+ while (map->baud) {
+ if (map->baud == baud)
+ return map->speed;
+ map++;
+ }
+
+ /*
+ * If a non-standard BAUD rate is used, issue
+ * a warning (if we are verbose) and return the raw rate
+ */
+ if (verbose > 0)
+ fprintf(stderr, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
+ progname, baud);
+
+ return baud;
+}
+
+
+static BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms
+{
+ COMMTIMEOUTS ctmo;
+ ZeroMemory (&ctmo, sizeof(COMMTIMEOUTS));
+ ctmo.ReadIntervalTimeout = timeout;
+ ctmo.ReadTotalTimeoutMultiplier = timeout;
+ ctmo.ReadTotalTimeoutConstant = timeout;
+
+ return SetCommTimeouts(hComPort, &ctmo);
+}
+
+static int ser_setspeed(union filedescriptor *fd, long baud)
+{
+ DCB dcb;
+ HANDLE hComPort = (HANDLE)fd->pfd;
+
+ ZeroMemory (&dcb, sizeof(DCB));
+ dcb.DCBlength = sizeof(DCB);
+ dcb.BaudRate = serial_baud_lookup (baud);
+ dcb.fBinary = 1;
+ dcb.fDtrControl = DTR_CONTROL_DISABLE;
+ dcb.fRtsControl = RTS_CONTROL_DISABLE;
+ dcb.ByteSize = 8;
+ dcb.Parity = NOPARITY;
+ dcb.StopBits = ONESTOPBIT;
+
+ if (!SetCommState(hComPort, &dcb))
+ return -1;
+
+ return 0;
+}
+
+
+static int ser_open(char * port, long baud, union filedescriptor *fdp)
+{
+ LPVOID lpMsgBuf;
+ HANDLE hComPort=INVALID_HANDLE_VALUE;
+ char *newname = 0;
+
+ /*
+ * If the port is of the form "net:<host>:<port>", then
+ * handle it as a TCP connection to a terminal server.
+ *
+ * This is curently not implemented for Win32.
+ */
+ if (strncmp(port, "net:", strlen("net:")) == 0) {
+ fprintf(stderr,
+ "%s: ser_open(): network connects are currently not"
+ "implemented for Win32 environments\n",
+ progname);
+ return -1;
+ }
+
+ if (strncasecmp(port, "com", strlen("com")) == 0) {
+
+ // prepend "\\\\.\\" to name, required for port # >= 10
+ newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);
+
+ if (newname == 0) {
+ fprintf(stderr,
+ "%s: ser_open(): out of memory\n",
+ progname);
+ exit(1);
+ }
+ strcpy(newname, "\\\\.\\");
+ strcat(newname, port);
+
+ port = newname;
+ }
+
+ hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (hComPort == INVALID_HANDLE_VALUE) {
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL);
+ fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
+ progname, port, (char*)lpMsgBuf);
+ LocalFree( lpMsgBuf );
+ return -1;
+ }
+
+ if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
+ {
+ CloseHandle(hComPort);
+ fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n",
+ progname, port);
+ return -1;
+ }
+
+ fdp->pfd = (void *)hComPort;
+ if (ser_setspeed(fdp, baud) != 0)
+ {
+ CloseHandle(hComPort);
+ fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",
+ progname, port);
+ return -1;
+ }
+
+ if (!serial_w32SetTimeOut(hComPort,0))
+ {
+ CloseHandle(hComPort);
+ fprintf(stderr, "%s: ser_open(): can't set initial timeout for \"%s\"\n",
+ progname, port);
+ return -1;
+ }
+
+ if (newname != 0) {
+ free(newname);
+ }
+ return 0;
+}
+
+
+static void ser_close(union filedescriptor *fd)
+{
+ HANDLE hComPort=(HANDLE)fd->pfd;
+ if (hComPort != INVALID_HANDLE_VALUE)
+ CloseHandle (hComPort);
+
+ hComPort = INVALID_HANDLE_VALUE;
+}
+
+static int ser_set_dtr_rts(union filedescriptor *fd, int is_on)
+{
+ HANDLE hComPort=(HANDLE)fd->pfd;
+
+ if (is_on) {
+ EscapeCommFunction(hComPort, SETDTR);
+ EscapeCommFunction(hComPort, SETRTS);
+ } else {
+ EscapeCommFunction(hComPort, CLRDTR);
+ EscapeCommFunction(hComPort, CLRRTS);
+ }
+ return 0;
+}
+
+
+static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
+{
+ size_t len = buflen;
+ unsigned char c='\0';
+ DWORD written;
+ unsigned char * b = buf;
+
+ HANDLE hComPort=(HANDLE)fd->pfd;
+
+ if (hComPort == INVALID_HANDLE_VALUE) {
+ fprintf(stderr, "%s: ser_send(): port not open\n",
+ progname);
+ exit(1);
+ }
+
+ if (!len)
+ return 0;
+
+ if (verbose > 3)
+ {
+ fprintf(stderr, "%s: Send: ", progname);
+
+ while (len) {
+ c = *b;
+ if (isprint(c)) {
+ fprintf(stderr, "%c ", c);
+ }
+ else {
+ fprintf(stderr, ". ");
+ }
+ fprintf(stderr, "[%02x] ", c);
+ b++;
+ len--;
+ }
+ fprintf(stderr, "\n");
+ }
+
+ serial_w32SetTimeOut(hComPort,500);
+
+ if (!WriteFile (hComPort, buf, buflen, &written, NULL)) {
+ fprintf(stderr, "%s: ser_send(): write error: %s\n",
+ progname, "sorry no info avail"); // TODO
+ exit(1);
+ }
+
+ if (written != buflen) {
+ fprintf(stderr, "%s: ser_send(): size/send mismatch\n",
+ progname);
+ exit(1);
+ }
+
+ return 0;
+}
+
+
+static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen)
+{
+ unsigned char c;
+ unsigned char * p = buf;
+ DWORD read;
+
+ HANDLE hComPort=(HANDLE)fd->pfd;
+
+ if (hComPort == INVALID_HANDLE_VALUE) {
+ fprintf(stderr, "%s: ser_read(): port not open\n",
+ progname);
+ exit(1);
+ }
+
+ serial_w32SetTimeOut(hComPort, serial_recv_timeout);
+
+ if (!ReadFile(hComPort, buf, buflen, &read, NULL)) {
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL );
+ fprintf(stderr, "%s: ser_recv(): read error: %s\n",
+ progname, (char*)lpMsgBuf);
+ LocalFree( lpMsgBuf );
+ exit(1);
+ }
+
+ /* time out detected */
+ if (read == 0) {
+ if (verbose > 1)
+ fprintf(stderr,
+ "%s: ser_recv(): programmer is not responding\n",
+ progname);
+ return -1;
+ }
+
+ p = buf;
+
+ if (verbose > 3)
+ {
+ fprintf(stderr, "%s: Recv: ", progname);
+
+ while (read) {
+ c = *p;
+ if (isprint(c)) {
+ fprintf(stderr, "%c ", c);
+ }
+ else {
+ fprintf(stderr, ". ");
+ }
+ fprintf(stderr, "[%02x] ", c);
+
+ p++;
+ read--;
+ }
+ fprintf(stderr, "\n");
+ }
+ return 0;
+}
+
+
+static int ser_drain(union filedescriptor *fd, int display)
+{
+ // int rc;
+ unsigned char buf[10];
+ BOOL readres;
+ DWORD read;
+
+ HANDLE hComPort=(HANDLE)fd->pfd;
+
+ if (hComPort == INVALID_HANDLE_VALUE) {
+ fprintf(stderr, "%s: ser_drain(): port not open\n",
+ progname);
+ exit(1);
+ }
+
+ serial_w32SetTimeOut(hComPort,250);
+
+ if (display) {
+ fprintf(stderr, "drain>");
+ }
+
+ while (1) {
+ readres=ReadFile(hComPort, buf, 1, &read, NULL);
+ if (!readres) {
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL );
+ fprintf(stderr, "%s: ser_drain(): read error: %s\n",
+ progname, (char*)lpMsgBuf);
+ LocalFree( lpMsgBuf );
+ exit(1);
+ }
+
+ if (read) { // data avail
+ if (display) fprintf(stderr, "%02x ", buf[0]);
+ }
+ else { // no more data
+ if (display) fprintf(stderr, "<drain\n");
+ break;
+ }
+ } // while
+ return 0;
+}
+
+struct serial_device serial_serdev =
+{
+ .open = ser_open,
+ .setspeed = ser_setspeed,
+ .close = ser_close,
+ .send = ser_send,
+ .recv = ser_recv,
+ .drain = ser_drain,
+ .set_dtr_rts = ser_set_dtr_rts,
+ .flags = SERDEV_FL_CANSETSPEED,
+};
+
+struct serial_device *serdev = &serial_serdev;
+
+#endif /* WIN32NATIVE */