summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-08-21 00:19:45 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-20 22:59:54 -0700
commit8d73e4f81c384c36e5ed3b8848253fd1e0b70692 (patch)
treee1860dd7367b1281211665f01dcfaacc397c6f54
parente2c98def2699c6ed4b98633f780ef3faaf903335 (diff)
downloadsubsurface-8d73e4f81c384c36e5ed3b8848253fd1e0b70692.tar.gz
Connect up serial_ftdi custom serial
This connects the serial_ftdi implementation to subsurface, and builds libftdi1 for the android builds. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--CMakeLists.txt12
-rw-r--r--libdivecomputer.c11
-rw-r--r--libdivecomputer.h1
-rw-r--r--packaging/android/build.sh21
4 files changed, 43 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92f9e94b2..7c74e3551 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
option(SUBSURFACE_MOBILE "build the QtQuick version for mobile device" OFF)
option(FBSUPPORT "allow posting to Facebook" ON)
option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
+option(FTDISUPPORT "enable support for libftdi based serial" OFF)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
@@ -118,6 +119,16 @@ if(NOT NO_MARBLE)
endif()
endif()
+if(FTDISUPPORT)
+ message(STATUS "building with libftdi support")
+ pkg_config_library(LIBFTDI libftdi QUIET)
+ if (NOT LIBFTDI_FOUND)
+ pkg_config_library(LIBFTDI libftdi1 REQUIRED)
+ endif()
+ set(SERIAL_FTDI serial_ftdi.c)
+ add_definitions(-DSERIAL_FTDI)
+endif()
+
if(NO_MARBLE)
message(STATUS "building without marble widget support")
add_definitions(-DNO_MARBLE)
@@ -341,6 +352,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
divelogexportlogic.cpp
qt-init.cpp
qtserialbluetooth.cpp
+ ${SERIAL_FTDI}
${PLATFORM_SRC}
)
source_group("Subsurface Core" FILES ${SUBSURFACE_CORE_LIB_SRCS})
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 64e76e389..bbabb1c1c 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -925,10 +925,17 @@ const char *do_libdivecomputer_import(device_data_t *data)
err = translate("gettextFromC", "Unable to open %s %s (%s)");
#if defined(SSRF_CUSTOM_SERIAL)
- if (data->bluetooth_mode) {
- dc_serial_t *serial_device;
+ dc_serial_t *serial_device = NULL;
+ if (data->bluetooth_mode) {
rc = dc_serial_qt_open(&serial_device, data->context, data->devname);
+#ifdef SERIAL_FTDI
+ } else if (!strcmp(data->devname, "ftdi")) {
+ rc = dc_serial_ftdi_open(&serial_device, data->context);
+#endif
+ }
+
+ if (serial_device) {
if (rc == DC_STATUS_SUCCESS) {
rc = dc_device_custom_open(&data->device, data->context, data->descriptor, serial_device);
} else {
diff --git a/libdivecomputer.h b/libdivecomputer.h
index 911b7d0cd..79817e509 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -56,6 +56,7 @@ extern char *dumpfile_name;
#if SSRF_CUSTOM_SERIAL
extern dc_status_t dc_serial_qt_open(dc_serial_t **out, dc_context_t *context, const char *devaddr);
+extern dc_status_t dc_serial_ftdi_open(dc_serial_t **out, dc_context_t *context);
#endif
#ifdef __cplusplus
diff --git a/packaging/android/build.sh b/packaging/android/build.sh
index fef8ecb55..1c72ab1b9 100644
--- a/packaging/android/build.sh
+++ b/packaging/android/build.sh
@@ -28,6 +28,7 @@ LIBGIT2_VERSION=0.23.0
LIBSSH2_VERSION=1.6.0
LIBUSB_VERSION=1.0.19
OPENSSL_VERSION=1.0.1p
+LIBFTDI_VERSION=1.2
# arm or x86
export ARCH=${1-arm}
@@ -228,6 +229,25 @@ if [ ! -e $PKG_CONFIG_LIBDIR/libusb-1.0.pc ] ; then
sed -ie 's/Libs.private: -c/Libs.private: /' $PKG_CONFIG_LIBDIR/libusb-1.0.pc
fi
+if [ ! -e libftdi1-${LIBFTDI_VERSION}.tar.bz2 ] ; then
+ wget -O libftdi1-${LIBFTDI_VERSION}.tar.bz2 http://www.intra2net.com/en/developer/libftdi/download/libftdi1-${LIBFTDI_VERSION}.tar.bz2
+fi
+if [ ! -e libftdi1-${LIBFTDI_VERSION} ] ; then
+ tar -jxf libftdi1-${LIBFTDI_VERSION}.tar.bz2
+fi
+if [ ! -e $PKG_CONFIG_LIBDIR/libftdi1.pc ] ; then
+ mkdir -p libftdi1-build-$ARCH
+ pushd libftdi1-build-$ARCH
+ cmake ../libftdi1-${LIBFTDI_VERSION} -DCMAKE_C_COMPILER=${CC} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} -DSTATICLIBS=ON -DPYTHON_BINDINGS=OFF -DDOCUMENTATION=OFF -DFTDIPP=OFF -DBUILD_TESTS=OFF -DEXAMPLES=OFF
+ make
+ make install
+ popd
+fi
+# Blast away the shared version to force static linking
+if [ -e $PREFIX/lib/libftdi1.so ] ; then
+ rm $PREFIX/lib/libftdi1.so*
+fi
+
if [ ! -e $PKG_CONFIG_LIBDIR/libdivecomputer.pc ] ; then
mkdir -p libdivecomputer-build-$ARCH
pushd libdivecomputer-build-$ARCH
@@ -278,6 +298,7 @@ cmake $MOBILE_CMAKE \
-DNO_USERMANUAL=ON \
-DCMAKE_PREFIX_PATH:UNINITIALIZED=${QT5_ANDROID}/android_${QT_ARCH}/lib/cmake \
-DCMAKE_BUILD_TYPE=Debug \
+ -DFTDISUPPORT=ON \
$SUBSURFACE_SOURCE
make
#make install INSTALL_ROOT=android_build