diff --git a/FlippR-Driver/CMakeLists.txt b/FlippR-Driver/CMakeLists.txt index 7972bc2..d015430 100644 --- a/FlippR-Driver/CMakeLists.txt +++ b/FlippR-Driver/CMakeLists.txt @@ -28,28 +28,12 @@ IF(NOT RPI_ROOT) set(RPI_TOOLCHAIN ${RPI_ROOT}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin) ENDIF() -IF(CROSS_COMPILE) - SET(CMAKE_CROSSCOMPILING TRUE) - #SET(CMAKE_TOOLCHAIN_FILE ${RPI_ROOT}/Toolchain-RaspberryPi.cmake) - SET(CMAKE_SYSTEM_NAME Linux) - SET(CMAKE_SYSTEM_VERSION 1) - - # Specify the cross compiler - SET(CMAKE_C_COMPILER /usr/bin/clang) - SET(CMAKE_CXX_COMPILER /usr/bin/clang) - - # Where is the target environment - SET(CMAKE_FIND_ROOT_PATH ${RPI_ROOT}/rootfs) - # SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs) - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -ENDIF(CROSS_COMPILE) - ###################### START_CMAKE ####################### cmake_minimum_required(VERSION 3.0.1) project(FlippR-Driver VERSION 0.1.0)# LANGUAGES CXX) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + #set easylogging flags add_definitions(-DELPP_NO_DEFAULT_LOG_FILE) @@ -102,7 +86,10 @@ endif(Boost_FOUND) ##################### WIRING_PI ########################## find_library(wiringPi_LIB wiringPi) if(NOT wiringPi_LIB) - message(FATAL_ERROR "Could not find wiringPi library") + message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.") + add_definitions(-DNO_WIRING_PI) +else() + message (STATUS "Found wiring pi.") endif() target_link_libraries(${PROJECT_NAME} PUBLIC ${wiringPi_LIB}) diff --git a/FlippR-Driver/cli/networking/flippR_driver_networking b/FlippR-Driver/cli/networking/flippR_driver_networking new file mode 100755 index 0000000..9ff0543 Binary files /dev/null and b/FlippR-Driver/cli/networking/flippR_driver_networking differ diff --git a/FlippR-Driver/cli/networking/server_config.json b/FlippR-Driver/cli/networking/server_config.json new file mode 100644 index 0000000..efe81b5 --- /dev/null +++ b/FlippR-Driver/cli/networking/server_config.json @@ -0,0 +1,9 @@ +{ + "input-config" :"../../contrib/json_example/input/Input_Pin_Config.json", + "matrix-config" :"../../contrib/json_example/input/Input_Matrix_Config.json", + "lamp-config" :"../../contrib/json_example/output/Lamp_Config.json", + "solenoid-config" :"../../contrib/json_example/output/Solenoid_Config.json", + "sound-config" :"../../contrib/json_example/output/Sound_Config.json", + "display-config" :"../../contrib/json_example/output/Display_Config.json", + "lamp-config" :"../../contrib/json_example/output/Lamp_Config.json" +} diff --git a/FlippR-Driver/cmake/CXX1x.cmake b/FlippR-Driver/cmake/CXX1x.cmake new file mode 100644 index 0000000..5f48eb7 --- /dev/null +++ b/FlippR-Driver/cmake/CXX1x.cmake @@ -0,0 +1,81 @@ +# Copyright (c) 2013 Nathan Osman + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Determines whether the compiler supports C++11 +macro(check_for_cxx11_compiler _VAR) + message(STATUS "Checking for C++11 compiler") + set(${_VAR}) + try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON) + if(NOT _COMPILER_TEST_RESULT AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON) + if(_COMPILER_TEST_RESULT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + else() + message(STATUS "To enable C++11 install libc++ standard library from https://libcxx.llvm.org/") + endif() + endif() + if(_COMPILER_TEST_RESULT AND ((MSVC AND (MSVC10 OR MSVC11 OR MSVC12 OR MSVC14)) OR + (CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.1) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.3) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))) + set(${_VAR} 1) + message(STATUS "Checking for C++11 compiler - available") + else() + message(STATUS "Checking for C++11 compiler - unavailable") + endif() +endmacro() + +# Sets the appropriate flag to enable C++11 support +macro(enable_cxx11) + set (CMAKE_CXX_STANDARD 11) + set (CMAKE_CXX_STANDARD_REQUIRED ON) + add_definitions(-DPOCO_ENABLE_CPP11) +endmacro() + +# Determines whether the compiler supports C++14 +macro(check_for_cxx14_compiler _VAR) + message(STATUS "Checking for C++14 compiler") + set(${_VAR}) + try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON) + if(NOT _COMPILER_TEST_RESULT AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON) + if(_COMPILER_TEST_RESULT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + else() + message(STATUS "To enable C++14 install libc++ standard library from https://libcxx.llvm.org/") + endif() + endif() + if(_COMPILER_TEST_RESULT AND ((MSVC AND (MSVC14)) OR + (CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.9.2) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.4) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))) + set(${_VAR} 1) + message(STATUS "Checking for C++14 compiler - available") + else() + message(STATUS "Checking for C++14 compiler - unavailable") + endif() +endmacro() + +# Sets the appropriate flag to enable C++14 support +macro(enable_cxx14) + set (CMAKE_CXX_STANDARD 14) + set (CMAKE_CXX_STANDARD_REQUIRED ON) + add_definitions(-DPOCO_ENABLE_CPP14) +endmacro() diff --git a/FlippR-Driver/cmake/DefinePlatformSpecifc.cmake b/FlippR-Driver/cmake/DefinePlatformSpecifc.cmake new file mode 100644 index 0000000..b296405 --- /dev/null +++ b/FlippR-Driver/cmake/DefinePlatformSpecifc.cmake @@ -0,0 +1,132 @@ +# http://www.cmake.org/Wiki/CMake_Useful_Variables : +# CMAKE_BUILD_TYPE +# Choose the type of build. CMake has default flags for these: +# +# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used) +# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG) +# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE) +# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO +# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL) + +# Setting CXX Flag /MD or /MT and POSTFIX values i.e MDd / MD / MTd / MT / d +# +# For visual studio the library naming is as following: +# Dynamic libraries: +# - PocoX.dll for release library +# - PocoXd.dll for debug library +# +# Static libraries: +# - PocoXmd.lib for /MD release build +# - PocoXtmt.lib for /MT release build +# +# - PocoXmdd.lib for /MD debug build +# - PocoXmtd.lib for /MT debug build + +if(MSVC) + if(POCO_MT) + set(CompilerFlags + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + ) + foreach(CompilerFlag ${CompilerFlags}) + string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") + endforeach() + + set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE) + else(POCO_MT) + set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE) + endif(POCO_MT) + + if (ENABLE_MSVC_MP) + add_definitions(/MP) + endif() + +else(MSVC) + # Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment + set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") +endif(MSVC) + + + +# Add a d postfix to the debug libraries +if(POCO_STATIC) + set(CMAKE_DEBUG_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set Debug library postfix" FORCE) + set(CMAKE_RELEASE_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set Release library postfix" FORCE) + set(CMAKE_MINSIZEREL_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set MinSizeRel library postfix" FORCE) + set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set RelWithDebInfo library postfix" FORCE) +else(POCO_STATIC) + set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set Debug library postfix" FORCE) + set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix" FORCE) + set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinSizeRel library postfix" FORCE) + set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "Set RelWithDebInfo library postfix" FORCE) +endif() + + +# OS Detection +include(CheckTypeSize) +find_package(Cygwin) + +if(WIN32) + add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE -D__LCC__) #__LCC__ define used by MySQL.h +endif(WIN32) + +if (CYGWIN) + add_definitions(-DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING) + add_definitions(-D_XOPEN_SOURCE=500 -D__BSD_VISIBLE) +else (CYGWIN) + if (UNIX AND NOT ANDROID ) + add_definitions( -DPOCO_OS_FAMILY_UNIX ) + # Standard 'must be' defines + if (APPLE) + add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64) + set(SYSLIBS ${CMAKE_DL_LIBS}) + else (APPLE) + add_definitions( -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) + if (QNX) + add_definitions( -DPOCO_HAVE_FD_POLL) + set(SYSLIBS m socket) + else (QNX) + add_definitions( -D_XOPEN_SOURCE=500) + if (${CMAKE_SYSTEM} MATCHES "AIX") + add_definitions( -DPOCO_HAVE_FD_POLL) + else() + add_definitions( -DPOCO_HAVE_FD_EPOLL) + endif() + set(SYSLIBS pthread ${CMAKE_DL_LIBS} rt) + endif (QNX) + endif (APPLE) + endif(UNIX AND NOT ANDROID ) +endif (CYGWIN) + +if (CMAKE_SYSTEM MATCHES "SunOS") + add_definitions( -DPOCO_OS_FAMILY_UNIX ) + # Standard 'must be' defines + add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) + set(SYSLIBS pthread socket xnet nsl resolv rt ${CMAKE_DL_LIBS}) +endif(CMAKE_SYSTEM MATCHES "SunOS") + +if (CMAKE_COMPILER_IS_MINGW) + add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) + add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE) +endif (CMAKE_COMPILER_IS_MINGW) + +# SunPro C++ +if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") + add_definitions( -D_BSD_SOURCE -library=stlport4) +endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") + +# iOS +if (IOS) + add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES ) +endif(IOS) + +#Android +if (ANDROID) + add_definitions( -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY ) +endif(ANDROID) diff --git a/FlippR-Driver/cmake/ExecuteOnAndroid.cmake b/FlippR-Driver/cmake/ExecuteOnAndroid.cmake new file mode 100644 index 0000000..e944c23 --- /dev/null +++ b/FlippR-Driver/cmake/ExecuteOnAndroid.cmake @@ -0,0 +1,29 @@ + +get_filename_component(UNITTEST_FILENAME ${UNITTEST} NAME) +message(STATUS "Cleanup /data/local/tmp ...") +execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "rm -r /data/local/tmp/*" OUTPUT_QUIET) +foreach(_TEST_DATA IN ITEMS ${TEST_FILES}) + message(STATUS "Push ${_TEST_DATA} to android ...") + execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${_TEST_DATA} /data/local/tmp/ OUTPUT_QUIET) +endforeach() +message(STATUS "Push ${LIBRARY_DIR} to android ...") +execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${LIBRARY_DIR} /data/local/tmp/ OUTPUT_QUIET) +message(STATUS "Push ${UNITTEST} to android ...") +execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${UNITTEST} /data/local/tmp/ OUTPUT_QUIET) +message(STATUS "Execute ${UNITTEST_FILENAME} ${TEST_PARAMETER} on android ...") +execute_process( + COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "cd /data/local/tmp;su root sh -c 'LD_LIBRARY_PATH=/data/local/tmp/lib TMPDIR=/data/local/tmp HOME=/data/local/tmp ./${UNITTEST_FILENAME} ${TEST_PARAMETER};echo exit code $?'" + RESULT_VARIABLE _RESULT + OUTPUT_VARIABLE _OUT + ERROR_VARIABLE _ERR +) + +if(_RESULT) + message(FATAL_ERROR "Execution of ${UNITTEST_FILENAME} failed") +else() + string(REGEX MATCH "exit code ([0-9]+)" _EXIT_CODE ${_OUT}) + if(NOT "${CMAKE_MATCH_1}" EQUAL 0) + string(REGEX REPLACE "exit code [0-9]+" "" _PRINT_OUT ${_OUT}) + message(FATAL_ERROR "${UNITTEST_FILENAME} execution error: ${_PRINT_OUT} ${_ERR}") + endif() +endif() diff --git a/FlippR-Driver/cmake/FindAPR.cmake b/FlippR-Driver/cmake/FindAPR.cmake new file mode 100644 index 0000000..3a7a11c --- /dev/null +++ b/FlippR-Driver/cmake/FindAPR.cmake @@ -0,0 +1,94 @@ +# -*- cmake -*- + +# - Find Apache Portable Runtime +# Find the APR includes and libraries +# This module defines +# APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR, where to find apr.h, etc. +# APR_LIBRARIES and APRUTIL_LIBRARIES, the libraries needed to use APR. +# APR_FOUND and APRUTIL_FOUND, If false, do not try to use APR. +# also defined, but not for general use are +# APR_LIBRARY and APRUTIL_LIBRARY, where to find the APR library. + +# APR first. + +FIND_PATH(APR_INCLUDE_DIR apr.h +/usr/local/include/apr-1 +/usr/local/include/apr-1.0 +/usr/include/apr-1 +/usr/include/apr-1.0 +) + +SET(APR_NAMES ${APR_NAMES} apr-1) +FIND_LIBRARY(APR_LIBRARY + NAMES ${APR_NAMES} + PATHS /usr/lib /usr/local/lib + ) + +IF (APR_LIBRARY AND APR_INCLUDE_DIR) + SET(APR_LIBRARIES ${APR_LIBRARY}) + SET(APR_FOUND "YES") +ELSE (APR_LIBRARY AND APR_INCLUDE_DIR) + SET(APR_FOUND "NO") +ENDIF (APR_LIBRARY AND APR_INCLUDE_DIR) + + +IF (APR_FOUND) + IF (NOT APR_FIND_QUIETLY) + MESSAGE(STATUS "Found APR: ${APR_LIBRARIES}") + ENDIF (NOT APR_FIND_QUIETLY) +ELSE (APR_FOUND) + IF (APR_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find APR library") + ENDIF (APR_FIND_REQUIRED) +ENDIF (APR_FOUND) + +# Deprecated declarations. +SET (NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_APR_LIB_PATH ${APR_LIBRARY} PATH) + +MARK_AS_ADVANCED( + APR_LIBRARY + APR_INCLUDE_DIR + ) + +# Next, APRUTIL. + +FIND_PATH(APRUTIL_INCLUDE_DIR apu.h +/usr/local/include/apr-1 +/usr/local/include/apr-1.0 +/usr/include/apr-1 +/usr/include/apr-1.0 +) + +SET(APRUTIL_NAMES ${APRUTIL_NAMES} aprutil-1) +FIND_LIBRARY(APRUTIL_LIBRARY + NAMES ${APRUTIL_NAMES} + PATHS /usr/lib /usr/local/lib + ) + +IF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + SET(APRUTIL_LIBRARIES ${APRUTIL_LIBRARY}) + SET(APRUTIL_FOUND "YES") +ELSE (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + SET(APRUTIL_FOUND "NO") +ENDIF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + + +IF (APRUTIL_FOUND) + IF (NOT APRUTIL_FIND_QUIETLY) + MESSAGE(STATUS "Found APRUTIL: ${APRUTIL_LIBRARIES}") + ENDIF (NOT APRUTIL_FIND_QUIETLY) +ELSE (APRUTIL_FOUND) + IF (APRUTIL_FIND_REQUIRED) + MESSAGE(STATUS "Could not find APRUTIL library") + ENDIF (APRUTIL_FIND_REQUIRED) +ENDIF (APRUTIL_FOUND) + +# Deprecated declarations. +SET (NATIVE_APRUTIL_INCLUDE_PATH ${APRUTIL_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_APRUTIL_LIB_PATH ${APRUTIL_LIBRARY} PATH) + +MARK_AS_ADVANCED( + APRUTIL_LIBRARY + APRUTIL_INCLUDE_DIR + ) diff --git a/FlippR-Driver/cmake/FindApache2.cmake b/FlippR-Driver/cmake/FindApache2.cmake new file mode 100644 index 0000000..ea1dd02 --- /dev/null +++ b/FlippR-Driver/cmake/FindApache2.cmake @@ -0,0 +1,31 @@ +# -*- cmake -*- + +# - Find Apache Runtime +# Find the APACHE includes and libraries +# This module defines +# APACHE_INCLUDE_DIR and APACHEUTIL_INCLUDE_DIR, where to find APACHE.h, etc. +# APACHE_LIBRARIES and APACHEUTIL_LIBRARIES, the libraries needed to use APACHE. +# APACHE_FOUND and APACHEUTIL_FOUND, If false, do not try to use APACHE. +# also defined, but not for general use are +# APACHE_LIBRARY and APACHEUTIL_LIBRARY, where to find the APACHE library. + +FIND_PATH(APACHE_INCLUDE_DIR httpd.h +/usr/local/include/apache2 +/usr/include/apache2 +) + +IF (APACHE_INCLUDE_DIR) + SET(APACHE_FOUND "YES") +ELSE (APACHE_LIBRARY AND APACHE_INCLUDE_DIR) + SET(APACHE_FOUND "NO") +ENDIF (APACHE_INCLUDE_DIR) + + +IF (APACHE_FOUND) + MESSAGE(STATUS "Found APACHE: ${APACHE_INCLUDE_DIR}") +ENDIF (APACHE_FOUND) + +MARK_AS_ADVANCED( + APACHE_INCLUDE_DIR + ) + diff --git a/FlippR-Driver/cmake/FindMySQL.cmake b/FlippR-Driver/cmake/FindMySQL.cmake new file mode 100644 index 0000000..7499723 --- /dev/null +++ b/FlippR-Driver/cmake/FindMySQL.cmake @@ -0,0 +1,94 @@ +SET(BINDIR32_ENV_NAME "ProgramFiles(x86)") +SET(BINDIR32 $ENV{${BINDIR32_ENV_NAME}}) + +find_path(MYSQL_INCLUDE_DIR mysql.h + /usr/include/mysql + /usr/local/include/mysql + /opt/mysql/mysql/include + /opt/mysql/mysql/include/mysql + /usr/local/mysql/include + /usr/local/mysql/include/mysql + $ENV{MYSQL_INCLUDE_DIR} + $ENV{MYSQL_DIR}/include + $ENV{ProgramFiles}/MySQL/*/include + ${BINDIR32}/MySQL/include + $ENV{SystemDrive}/MySQL/*/include) + +if (NOT MYSQL_INCLUDE_DIR) + find_path(MARIADB_INCLUDE_DIR mysql.h + /usr/include/mariadb + /usr/local/include/mariadb + /opt/mariadb/mariadb/include + /opt/mariadb/mariadb/include/mariadb + /usr/local/mariadb/include + /usr/local/mariadb/include/mariadb + $ENV{MARIADB_INCLUDE_DIR} + $ENV{MARIADB_DIR}/include) +endif (NOT MYSQL_INCLUDE_DIR) + +if (WIN32) + if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(libsuffixDist debug) + set(libsuffixBuild Debug) + else (CMAKE_BUILD_TYPE STREQUAL Debug) + set(libsuffixDist opt) + set(libsuffixBuild Release) + add_definitions(-DDBUG_OFF) + endif (CMAKE_BUILD_TYPE STREQUAL Debug) + + find_library(MYSQL_LIB NAMES mysqlclient + PATHS + $ENV{MYSQL_DIR}/lib/${libsuffixDist} + $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} + $ENV{MYSQL_DIR}/client/${libsuffixBuild} + $ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist} + ${BINDIR32}/MySQL/lib + $ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist}) +else (WIN32) + find_library(MYSQL_LIB NAMES mysqlclient mysqlclient_r + PATHS + /usr/lib/mysql + /usr/local/lib/mysql + /usr/local/mysql/lib + /usr/local/mysql/lib/mysql + /opt/mysql/mysql/lib + /opt/mysql/mysql/lib/mysql + $ENV{MYSQL_DIR}/libmysql_r/.libs + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/lib/mysql) + + if (NOT MYSQL_LIB) + find_library(MARIADB_LIB NAMES mariadbclient + PATHS + /usr/lib/mariadb + /usr/local/lib/mariadb + /usr/local/mariadb/lib + /usr/local/mariadb/lib/mariadb + /opt/mariadb/mariadb/lib + /opt/mariadb/mariadb/lib/mariadb + $ENV{MARIADB_DIR}/libmariadb/.libs + $ENV{MARIADB_DIR}/lib + $ENV{MARIADB_DIR}/lib/mariadb) + endif (NOT MYSQL_LIB) +endif (WIN32) + +if (MYSQL_INCLUDE_DIR AND MYSQL_LIB) + get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIB} PATH) + set(MYSQL_FOUND TRUE) + message(STATUS "Found MySQL Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}") + include_directories(${MYSQL_INCLUDE_DIR}) + link_directories(${MYSQL_LIB_DIR}) +elseif((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB) + get_filename_component(MYSQL_LIB_DIR ${MARIADB_LIB} PATH) + set(MYSQL_FOUND TRUE) + set(MYSQL_LIB ${MARIADB_LIB}) + if(MARIADB_INCLUDE_DIR) + set(MYSQL_INCLUDE_DIR ${MARIADB_INCLUDE_DIR}) + endif(MARIADB_INCLUDE_DIR) + message(STATUS "Found MariaDB Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}") + message(STATUS "Use MariaDB for MySQL Support") + include_directories(${MYSQL_INCLUDE_DIR} ) + link_directories(${MYSQL_LIB_DIR}) +else ((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB) + message(STATUS "Couldn't find MySQL or MariaDB") +endif (MYSQL_INCLUDE_DIR AND MYSQL_LIB) diff --git a/FlippR-Driver/cmake/FindODBC.cmake b/FlippR-Driver/cmake/FindODBC.cmake new file mode 100644 index 0000000..b655b02 --- /dev/null +++ b/FlippR-Driver/cmake/FindODBC.cmake @@ -0,0 +1,61 @@ +# +# Find the ODBC driver manager includes and library. +# +# ODBC is an open standard for connecting to different databases in a +# semi-vendor-independent fashion. First you install the ODBC driver +# manager. Then you need a driver for each separate database you want +# to connect to (unless a generic one works). VTK includes neither +# the driver manager nor the vendor-specific drivers: you have to find +# those yourself. +# +# This module defines +# ODBC_INCLUDE_DIRECTORIES, where to find sql.h +# ODBC_LIBRARIES, the libraries to link against to use ODBC +# ODBC_FOUND. If false, you cannot build anything that requires MySQL. + +find_path(ODBC_INCLUDE_DIRECTORIES + NAMES sql.h + HINTS + /usr/include + /usr/include/odbc + /usr/include/iodbc + /usr/local/include + /usr/local/include/odbc + /usr/local/include/iodbc + /usr/local/odbc/include + /usr/local/iodbc/include + "C:/Program Files/ODBC/include" + "C:/Program Files/Microsoft SDKs/Windows/v7.0/include" + "C:/Program Files/Microsoft SDKs/Windows/v6.0a/include" + "C:/ODBC/include" + DOC "Specify the directory containing sql.h." +) + +find_library(ODBC_LIBRARIES + NAMES iodbc odbc odbcinst odbc32 + HINTS + /usr/lib + /usr/lib/odbc + /usr/local/lib + /usr/local/lib/odbc + /usr/local/odbc/lib + "C:/Program Files/ODBC/lib" + "C:/ODBC/lib/debug" + "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib" + DOC "Specify the ODBC driver manager library here." +) + +# MinGW find usually fails +if(MINGW) + set(ODBC_INCLUDE_DIRECTORIES ".") + set(ODBC_LIBRARIES odbc32) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ODBC + DEFAULT_MSG + ODBC_INCLUDE_DIRECTORIES + ODBC_LIBRARIES + ) + +mark_as_advanced(ODBC_FOUND ODBC_LIBRARIES ODBC_INCLUDE_DIRECTORIES) diff --git a/FlippR-Driver/cmake/FindPCRE.cmake b/FlippR-Driver/cmake/FindPCRE.cmake new file mode 100644 index 0000000..41a99cb --- /dev/null +++ b/FlippR-Driver/cmake/FindPCRE.cmake @@ -0,0 +1,33 @@ +# +# - Find pcre +# Find the native PCRE includes and library +# +# PCRE_INCLUDE_DIRS - where to find pcre.h, etc. +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + + +IF (PCRE_INCLUDE_DIRS) + # Already in cache, be silent + SET(PCRE_FIND_QUIETLY TRUE) +ENDIF (PCRE_INCLUDE_DIRS) + +FIND_PATH(PCRE_INCLUDE_DIR pcre.h) + +SET(PCRE_NAMES pcre) +FIND_LIBRARY(PCRE_LIBRARY NAMES ${PCRE_NAMES} ) + +# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) + +IF(PCRE_FOUND) + SET( PCRE_LIBRARIES ${PCRE_LIBRARY} ) + SET( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +ELSE(PCRE_FOUND) + SET( PCRE_LIBRARIES ) + SET( PCRE_INCLUDE_DIRS ) +ENDIF(PCRE_FOUND) + +MARK_AS_ADVANCED( PCRE_LIBRARIES PCRE_INCLUDE_DIRS ) diff --git a/FlippR-Driver/cmake/FindPostgreSQL.cmake b/FlippR-Driver/cmake/FindPostgreSQL.cmake new file mode 100644 index 0000000..6c383f0 --- /dev/null +++ b/FlippR-Driver/cmake/FindPostgreSQL.cmake @@ -0,0 +1,66 @@ +# - Find libpq +# Find the native PostgreSQL includes and library +# +# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc. +# PGSQL_LIBRARIES - List of libraries when using PGSQL. +# PGSQL_FOUND - True if PGSQL found. + +MACRO(FIND_PGSQL) +IF (PGSQL_INCLUDE_DIR) + # Already in cache, be silent + SET(PostgreSQL_FIND_QUIETLY TRUE) +ENDIF (PGSQL_INCLUDE_DIR) + +FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h + $ENV{ProgramFiles}/PostgreSQL/*/include + $ENV{SystemDrive}/PostgreSQL/*/include + /usr/local/pgsql/include + /usr/local/postgresql/include + /usr/local/include/pgsql + /usr/local/include/postgresql + /usr/local/include + /usr/include/pgsql + /usr/include/postgresql + /usr/include + /usr/pgsql/include + /usr/postgresql/include +) + +SET(PGSQL_NAMES pq libpq) +SET(PGSQL_SEARCH_LIB_PATHS + ${PGSQL_SEARCH_LIB_PATHS} + $ENV{ProgramFiles}/PostgreSQL/*/lib + $ENV{SystemDrive}/PostgreSQL/*/lib + /usr/local/pgsql/lib + /usr/local/lib + /usr/lib +) +FIND_LIBRARY(PGSQL_LIBRARY + NAMES ${PGSQL_NAMES} + PATHS ${PGSQL_SEARCH_LIB_PATHS} +) + +IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY) + SET(PGSQL_FOUND TRUE) + SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} ) +ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY) + SET(PGSQL_FOUND FALSE) + SET( PGSQL_LIBRARIES ) +ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY) + +IF (PGSQL_FOUND) + IF (NOT PostgreSQL_FIND_QUIETLY) + MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}") + ENDIF (NOT PostgreSQL_FIND_QUIETLY) +ELSE (PGSQL_FOUND) + IF (PostgreSQL_FIND_REQUIRED) + MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.") + MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library") + ENDIF (PostgreSQL_FIND_REQUIRED) +ENDIF (PGSQL_FOUND) + +MARK_AS_ADVANCED( + PGSQL_LIBRARY + PGSQL_INCLUDE_DIR +) +ENDMACRO(FIND_PGSQL) \ No newline at end of file diff --git a/FlippR-Driver/cmake/FindSQLite3.cmake b/FlippR-Driver/cmake/FindSQLite3.cmake new file mode 100644 index 0000000..aa650e3 --- /dev/null +++ b/FlippR-Driver/cmake/FindSQLite3.cmake @@ -0,0 +1,87 @@ +# - Try to find Sqlite3 +# Once done this will define +# +# SQLITE3_FOUND - system has Sqlite3 +# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory +# SQLITE3_LIBRARIES - Link these to use Sqlite3 +# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3 +# +# Copyright (c) 2008 Andreas Schneider +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # in cache already + set(SQLITE3_FOUND TRUE) +else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_SQLITE3 sqlite3) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_path(SQLITE3_INCLUDE_DIR + NAMES + sqlite3.h + PATHS + ${_SQLITE3_INCLUDEDIR} + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + + find_library(SQLITE3_LIBRARY + NAMES + sqlite3 + PATHS + ${_SQLITE3_LIBDIR} + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + if (SQLITE3_LIBRARY) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_LIBRARY) + + set(SQLITE3_INCLUDE_DIRS + ${SQLITE3_INCLUDE_DIR} + ) + + if (SQLITE3_FOUND) + set(SQLITE3_LIBRARIES + ${SQLITE3_LIBRARIES} + ${SQLITE3_LIBRARY} + ) + endif (SQLITE3_FOUND) + + if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + + if (SQLITE3_FOUND) + if (NOT Sqlite3_FIND_QUIETLY) + message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}") + endif (NOT Sqlite3_FIND_QUIETLY) + else (SQLITE3_FOUND) + if (Sqlite3_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Sqlite3") + endif (Sqlite3_FIND_REQUIRED) + endif (SQLITE3_FOUND) + + # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view + mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) + +endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + diff --git a/FlippR-Driver/cmake/PocoConfig.cmake.in b/FlippR-Driver/cmake/PocoConfig.cmake.in new file mode 100644 index 0000000..173eacd --- /dev/null +++ b/FlippR-Driver/cmake/PocoConfig.cmake.in @@ -0,0 +1,53 @@ +if (CMAKE_VERSION VERSION_LESS 2.8.9) + message(FATAL_ERROR "Poco requires at least CMake version 2.8.9") +endif() + +if (NOT Poco_FIND_COMPONENTS) + set(Poco_NOT_FOUND_MESSAGE "The Poco package requires at least one component") + set(Poco_FOUND False) + return() +endif() + +set(_Poco_FIND_PARTS_REQUIRED) +if (Poco_FIND_REQUIRED) + set(_Poco_FIND_PARTS_REQUIRED REQUIRED) +endif() +set(_Poco_FIND_PARTS_QUIET) +if (Poco_FIND_QUIETLY) + set(_Poco_FIND_PARTS_QUIET QUIET) +endif() + +get_filename_component(_Poco_install_prefix "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) + +set(_Poco_NOTFOUND_MESSAGE) + +# Let components find each other, but don't overwrite CMAKE_PREFIX_PATH +set(_Poco_CMAKE_PREFIX_PATH_old ${CMAKE_PREFIX_PATH}) +set(CMAKE_PREFIX_PATH ${_Poco_install_prefix}) + +foreach(module ${Poco_FIND_COMPONENTS}) + find_package(Poco${module} + ${_Poco_FIND_PARTS_QUIET} + ${_Poco_FIND_PARTS_REQUIRED} + PATHS "${_Poco_install_prefix}" NO_DEFAULT_PATH + ) + if (NOT Poco${module}_FOUND) + if (Poco_FIND_REQUIRED_${module}) + set(_Poco_NOTFOUND_MESSAGE "${_Poco_NOTFOUND_MESSAGE}Failed to find Poco component \"${module}\" config file at \"${_Poco_install_prefix}/Poco${module}/Poco${module}Config.cmake\"\n") + elseif(NOT Poco_FIND_QUIETLY) + message(WARNING "Failed to find Poco component \"${module}\" config file at \"${_Poco_install_prefix}/Poco${module}/Poco${module}Config.cmake\"") + endif() + endif() + + # For backward compatibility set the LIBRARIES variable + list(APPEND Poco_LIBRARIES "Poco::${module}") +endforeach() + +# Restore the original CMAKE_PREFIX_PATH value +set(CMAKE_PREFIX_PATH ${_Poco_CMAKE_PREFIX_PATH_old}) + +if (_Poco_NOTFOUND_MESSAGE) + set(Poco_NOT_FOUND_MESSAGE "${_Poco_NOTFOUND_MESSAGE}") + set(Poco_FOUND False) +endif() + diff --git a/FlippR-Driver/cmake/PocoConfigVersion.cmake.in b/FlippR-Driver/cmake/PocoConfigVersion.cmake.in new file mode 100644 index 0000000..98f292c --- /dev/null +++ b/FlippR-Driver/cmake/PocoConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION @APPLICATION_VERSION@) + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/FlippR-Driver/cmake/PocoMacros.cmake b/FlippR-Driver/cmake/PocoMacros.cmake new file mode 100644 index 0000000..4490b7b --- /dev/null +++ b/FlippR-Driver/cmake/PocoMacros.cmake @@ -0,0 +1,304 @@ +# Copyright Siemens AG, 2014 +# Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +# and Contributors. +# +# SPDX-License-Identifier: BSL-1.0 +# +# Collection of common functionality for Poco CMake + +# Find the Microsoft mc.exe message compiler +# +# CMAKE_MC_COMPILER - where to find mc.exe +if (WIN32) + # cmake has CMAKE_RC_COMPILER, but no message compiler + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # this path is only present for 2008+, but we currently require PATH to + # be set up anyway + get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH) + get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH) + get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH) + get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH) + get_filename_component(kit10wow_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH) + file(GLOB kit10_list ${kit10_dir}/bin/10.* ${kit10wow_dir}/bin/10.*) + if (X64) + set(sdk_bindir "${sdk_dir}/bin/x64") + set(kit_bindir "${kit_dir}/bin/x64") + set(kit81_bindir "${kit81_dir}/bin/x64") + foreach (tmp_elem ${kit10_list}) + if (IS_DIRECTORY ${tmp_elem}) + list(APPEND kit10_bindir "${tmp_elem}/x64") + endif() + endforeach() + else (X64) + set(sdk_bindir "${sdk_dir}/bin") + set(kit_bindir "${kit_dir}/bin/x86") + set(kit81_bindir "${kit81_dir}/bin/x86") + foreach (tmp_elem ${kit10_list}) + if (IS_DIRECTORY ${tmp_elem}) + list(APPEND kit10_bindir "${tmp_elem}/x86") + endif() + endforeach() + endif (X64) + endif () + find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}" ${kit10_bindir} + DOC "path to message compiler") + if (NOT CMAKE_MC_COMPILER) + message(FATAL_ERROR "message compiler not found: required to build") + endif (NOT CMAKE_MC_COMPILER) + message(STATUS "Found message compiler: ${CMAKE_MC_COMPILER}") + mark_as_advanced(CMAKE_MC_COMPILER) +endif(WIN32) + +#=============================================================================== +# Macros for Source file management +# +# POCO_SOURCES_PLAT - Adds a list of files to the sources of a components +# Usage: POCO_SOURCES_PLAT( out name platform sources) +# INPUT: +# out the variable the sources are added to +# name: the name of the components +# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...) +# sources: a list of files to add to ${out} +# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp ) +# +# POCO_SOURCES - Like POCO_SOURCES_PLAT with platform = ON (Built on all platforms) +# Usage: POCO_SOURCES( out name sources) +# Example: POCO_SOURCES( SRCS Foundation src/Foundation.cpp) +# +# POCO_SOURCES_AUTO - Like POCO_SOURCES but the name is read from the file header // Package: X +# Usage: POCO_SOURCES_AUTO( out sources) +# Example: POCO_SOURCES_AUTO( SRCS src/Foundation.cpp) +# +# POCO_SOURCES_AUTO_PLAT - Like POCO_SOURCES_PLAT but the name is read from the file header // Package: X +# Usage: POCO_SOURCES_AUTO_PLAT(out platform sources) +# Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp) +# +# +# POCO_HEADERS - Adds a list of files to the headers of a components +# Usage: POCO_HEADERS( out name headers) +# INPUT: +# out the variable the headers are added to +# name: the name of the components +# headers: a list of files to add to HDRSt +# Example: POCO_HEADERS( HDRS Foundation include/Poco/Foundation.h ) +# +# POCO_HEADERS_AUTO - Like POCO_HEADERS but the name is read from the file header // Package: X +# Usage: POCO_HEADERS_AUTO( out headers) +# Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp) +# +# +# POCO_MESSAGES - Adds a list of files to the messages of a components +# and adds the generated headers to the header list of the component. +# On platforms other then Windows this does nothing +# Usage: POCO_MESSAGES( out name messages) +# INPUT: +# out the variable the message and the resulting headers are added to +# name: the name of the components +# messages: a list of files to add to MSGS +# Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc ) +# + + +macro(POCO_SOURCES_PLAT out name platform) + source_group("${name}\\Source Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) + if(NOT (${platform})) + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + endif() +endmacro() + +macro(POCO_SOURCES out name) + POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN}) +endmacro() + +macro(POCO_SOURCES_AUTO out) + POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN}) +endmacro() + +macro(POCO_SOURCES_AUTO_PLAT out platform) + foreach( f ${ARGN}) + + get_filename_component(fname ${f} NAME) + + # Read the package name from the source file + file(STRINGS ${f} package REGEX "// Package: (.*)") + if(package) + string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) + + # Files of the Form X_UNIX.cpp are treated as headers + if(${fname} MATCHES ".*_.*\\..*") + #message(STATUS "Platform: ${name} ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} ${name} OFF ${f}) + else() + #message(STATUS "Source: ${name} ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f}) + endif() + else() + #message(STATUS "Source: Unknown ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f}) + endif() + endforeach() +endmacro() + + +macro(POCO_HEADERS_AUTO out) + foreach( f ${ARGN}) + + get_filename_component(fname ${f} NAME) + + # Read the package name from the source file + file(STRINGS ${f} package REGEX "// Package: (.*)") + if(package) + string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) + #message(STATUS "Header: ${name} ${f}") + POCO_HEADERS( ${out} ${name} ${f}) + else() + #message(STATUS "Header: Unknown ${f}") + POCO_HEADERS( ${out} Unknown ${f}) + endif() + endforeach() +endmacro() + +macro(POCO_HEADERS out name) + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + source_group("${name}\\Header Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) +endmacro() + + +macro(POCO_MESSAGES out name) + if (WIN32) + foreach(msg ${ARGN}) + get_filename_component(msg_name ${msg} NAME) + get_filename_component(msg_path ${msg} ABSOLUTE) + string(REPLACE ".mc" ".h" hdr ${msg_name}) + set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr} + DEPENDS ${msg} + COMMAND ${CMAKE_MC_COMPILER} + ARGS + -h ${CMAKE_CURRENT_BINARY_DIR} + -r ${CMAKE_CURRENT_BINARY_DIR} + ${msg_path} + VERBATIM # recommended: p260 + ) + + # Add the generated file to the include directory + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + + # Add the generated headers to POCO_HEADERS of the component + POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr}) + + endforeach() + + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + source_group("${name}\\Message Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) + + endif (WIN32) +endmacro() + + +#=============================================================================== +# Macros for Package generation +# +# POCO_GENERATE_PACKAGE - Generates *Config.cmake +# Usage: POCO_GENERATE_PACKAGE(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_GENERATE_PACKAGE(Foundation) +macro(POCO_GENERATE_PACKAGE target_name) +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) +if ("${CMAKE_VERSION}" VERSION_LESS "3.0.0") + if (NOT EXISTS "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake") + export(TARGETS "${target_name}" APPEND + FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + ) + endif () +else () + export(EXPORT "${target_name}Targets" + FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + ) +endif () +configure_file("cmake/Poco${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" + @ONLY +) + +set(ConfigPackageLocation "lib/cmake/${PROJECT_NAME}") + +install( + EXPORT "${target_name}Targets" + FILE "${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + DESTINATION "lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}" + ) + +install( + FILES + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" + DESTINATION "lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}" + COMPONENT Devel + ) + +endmacro() + +#=============================================================================== +# Macros for simplified installation +# +# POCO_INSTALL - Install the given target +# Usage: POCO_INSTALL(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL(Foundation) +macro(POCO_INSTALL target_name) +install( + DIRECTORY include/Poco + DESTINATION include + COMPONENT Devel + PATTERN ".svn" EXCLUDE + ) + +install( + TARGETS "${target_name}" EXPORT "${target_name}Targets" + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include + ) + +if (MSVC) +# install the targets pdb + POCO_INSTALL_PDB(${target_name}) +endif() + +endmacro() + +# POCO_INSTALL_PDB - Install the given target's companion pdb file (if present) +# Usage: POCO_INSTALL_PDB(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL_PDB(Foundation) +# +# This is an internal macro meant only to be used by POCO_INSTALL. +macro(POCO_INSTALL_PDB target_name) + + get_property(type TARGET ${target_name} PROPERTY TYPE) + if ("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE") + install( + FILES $ + DESTINATION bin + COMPONENT Devel + OPTIONAL + ) + endif() +endmacro() diff --git a/FlippR-Driver/cmake/README b/FlippR-Driver/cmake/README new file mode 100644 index 0000000..fae4a15 --- /dev/null +++ b/FlippR-Driver/cmake/README @@ -0,0 +1,36 @@ +CMAKE Files contributed by Andrew J. P. Maclean + + +Put the following files in the directory where your source code is: + CMakeLists.txt + PocoConfig.cmake. + +Edit CMakeLists.txt to include your source and header files. The sections of interest are: +# Add any source files here. +SET( EXE_SRCS + "My File.cpp" +) +# Add any include files here. +SET( EXE_INCS + "My File.h" +) + +Then create a subdirectory called build. +In Linux: +cd build +ccmake .. +or +ccmake -GKDevelop3 .. +(This will set up everything so you can use KDevelop3). + +In Windows: +run CMakeSetup.exe and set the source code directory and where to build the libraries. + +If CMake cannot find Poco, you will see that the variable Poco_INCLUDE_DIR has the value Poco_INCLUDE_DIR-NOTFOUND. Just set this value to the top level direcotry of where the Poco includes are. + +If there is a different version of Poco, you may have to add edit the variables SUFFIX_FOR_INCLUDE_PATH, and SUFFIX_FOR_LIBRARY_PATH adding in the new Poco version in a similar manner to the existing ones in the file PocoConfig.cmake. + +Finally: +In Linux + Either type "make" or if you are using KDevelop, click on the .kdevelop file. +In Windows just use your IDE or nmake if you use nmake. diff --git a/FlippR-Driver/cmake/cmake_uninstall.cmake.in b/FlippR-Driver/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000..03137d5 --- /dev/null +++ b/FlippR-Driver/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + IF(EXISTS "$ENV{DESTDIR}${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF("${rm_retval}" STREQUAL 0) + ELSE("${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF("${rm_retval}" STREQUAL 0) + ELSE(EXISTS "$ENV{DESTDIR}${file}") + MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + ENDIF(EXISTS "$ENV{DESTDIR}${file}") +ENDFOREACH(file) diff --git a/FlippR-Driver/cmake/test_compiler.cpp b/FlippR-Driver/cmake/test_compiler.cpp new file mode 100644 index 0000000..d9b7398 --- /dev/null +++ b/FlippR-Driver/cmake/test_compiler.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() +{ + std::string str = "Try to compile"; + std::cout << str << '\n'; + return 0; +} diff --git a/FlippR-Driver/contrib/json_example/output/Sound_Config.json b/FlippR-Driver/contrib/json_example/output/Sound_Config.json index ebda109..67b236c 100644 --- a/FlippR-Driver/contrib/json_example/output/Sound_Config.json +++ b/FlippR-Driver/contrib/json_example/output/Sound_Config.json @@ -188,7 +188,162 @@ "address" : "50", "description" : "Speech 1: \"You're good! But I'm still the Champ!\"", "extender" : "extender_0" + }, + { + "id" : 29, + "address" : "51", + "description" : "Speech 2: \"Twenty\"", + "extender" : "extender_0" + }, + { + "id" : 30, + "address" : "52", + "description" : "Speech 3: \"Seconds\"", + "extender" : "extender_0" + }, + { + "id" : 31, + "address" : "53", + "description" : "Speech 4: \"Five, Four, Three, Two, One.\"", + "extender" : "extender_0" + }, + { + "id" : 32, + "address" : "54", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 33, + "address" : "55", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 34, + "address" : "56", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 35, + "address" : "57", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 36, + "address" : "58", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 37, + "address" : "59", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 38, + "address" : "60", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 39, + "address" : "61", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 40, + "address" : "62", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 41, + "address" : "63", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 42, + "address" : "64", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 43, + "address" : "65", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 44, + "address" : "66", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 45, + "address" : "67", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 46, + "address" : "68", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 47, + "address" : "69", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 48, + "address" : "70", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 49, + "address" : "71", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 50, + "address" : "72", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 51, + "address" : "73", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 52, + "address" : "74", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 53, + "address" : "75", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" + }, + { + "id" : 54, + "address" : "76", + "description" : "speech 1: \"you're good! but i'm still the champ!\"", + "extender" : "extender_0" } - ] } diff --git a/FlippR-Driver/contrib/json_example/server_config.json b/FlippR-Driver/contrib/json_example/server_config.json index efe81b5..d8109d3 100644 --- a/FlippR-Driver/contrib/json_example/server_config.json +++ b/FlippR-Driver/contrib/json_example/server_config.json @@ -4,6 +4,5 @@ "lamp-config" :"../../contrib/json_example/output/Lamp_Config.json", "solenoid-config" :"../../contrib/json_example/output/Solenoid_Config.json", "sound-config" :"../../contrib/json_example/output/Sound_Config.json", - "display-config" :"../../contrib/json_example/output/Display_Config.json", - "lamp-config" :"../../contrib/json_example/output/Lamp_Config.json" + "display-config" :"../../contrib/json_example/output/Display_Config.json" } diff --git a/FlippR-Driver/lib/wiringPi/COPYING.LESSER b/FlippR-Driver/lib/wiringPi/COPYING.LESSER deleted file mode 100644 index 65c5ca8..0000000 --- a/FlippR-Driver/lib/wiringPi/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/FlippR-Driver/lib/wiringPi/Makefile b/FlippR-Driver/lib/wiringPi/Makefile deleted file mode 100644 index e1868b9..0000000 --- a/FlippR-Driver/lib/wiringPi/Makefile +++ /dev/null @@ -1,177 +0,0 @@ -# -# Makefile: -# wiringPi - Wiring Compatable library for the Raspberry Pi -# -# Copyright (c) 2012-2015 Gordon Henderson -################################################################################# -# This file is part of wiringPi: -# https://projects.drogon.net/raspberry-pi/wiringpi/ -# -# wiringPi is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# wiringPi 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with wiringPi. If not, see . -################################################################################# - -VERSION=$(shell cat ../VERSION) -DESTDIR?=/usr -PREFIX?=/local - -LDCONFIG?=ldconfig - -ifneq ($V,1) -Q ?= @ -endif - -STATIC=libwiringPi.a -DYNAMIC=libwiringPi.so.$(VERSION) - -#DEBUG = -g -O0 -DEBUG = -O2 -CC = gcc -INCLUDE = -I. -DEFS = -D_GNU_SOURCE -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC - -LIBS = -lm -lpthread -lrt -lcrypt - -############################################################################### - -SRC = wiringPi.c \ - wiringSerial.c wiringShift.c \ - piHiPri.c piThread.c \ - wiringPiSPI.c wiringPiI2C.c \ - softPwm.c softTone.c \ - mcp23008.c mcp23016.c mcp23017.c \ - mcp23s08.c mcp23s17.c \ - sr595.c \ - pcf8574.c pcf8591.c \ - mcp3002.c mcp3004.c mcp4802.c mcp3422.c \ - max31855.c max5322.c ads1115.c \ - sn3218.c \ - bmp180.c htu21d.c ds18b20.c rht03.c \ - drcSerial.c drcNet.c \ - pseudoPins.c \ - wpiExtensions.c - -HEADERS = $(shell ls *.h) - -OBJ = $(SRC:.c=.o) - -all: $(DYNAMIC) - -static: $(STATIC) - -$(STATIC): $(OBJ) - $Q echo "[Link (Static)]" - $Q ar rcs $(STATIC) $(OBJ) - $Q ranlib $(STATIC) -# @size $(STATIC) - -$(DYNAMIC): $(OBJ) - $Q echo "[Link (Dynamic)]" - $Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(LIBS) $(OBJ) - -.c.o: - $Q echo [Compile] $< - $Q $(CC) -c $(CFLAGS) $< -o $@ - - -.PHONY: clean -clean: - $Q echo "[Clean]" - $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.* - -.PHONY: tags -tags: $(SRC) - $Q echo [ctags] - $Q ctags $(SRC) - - -.PHONY: install -install: $(DYNAMIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Dynamic Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) - $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so - $Q $(LDCONFIG) - -.PHONY: install-static -install-static: $(STATIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Static Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib - -.PHONY: install-deb -install-deb: $(DYNAMIC) - $Q echo "[Install Headers: deb]" - $Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include - $Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include - $Q echo "[Install Dynamic Lib: deb]" - install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib - install -m 0755 libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) - ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so - -.PHONY: uninstall -uninstall: - $Q echo "[UnInstall]" - $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS) - $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.* - $Q $(LDCONFIG) - - -.PHONY: depend -depend: - makedepend -Y $(SRC) $(SRC_I2C) - -# DO NOT DELETE - -wiringPi.o: softPwm.h softTone.h wiringPi.h ../version.h -wiringSerial.o: wiringSerial.h -wiringShift.o: wiringPi.h wiringShift.h -piHiPri.o: wiringPi.h -piThread.o: wiringPi.h -wiringPiSPI.o: wiringPi.h wiringPiSPI.h -wiringPiI2C.o: wiringPi.h wiringPiI2C.h -softPwm.o: wiringPi.h softPwm.h -softTone.o: wiringPi.h softTone.h -mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h -mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h -mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h -mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h -mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h -sr595.o: wiringPi.h sr595.h -pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h -pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h -mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h -mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h -mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h -mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h -max31855.o: wiringPi.h wiringPiSPI.h max31855.h -max5322.o: wiringPi.h wiringPiSPI.h max5322.h -ads1115.o: wiringPi.h wiringPiI2C.h ads1115.h -sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h -bmp180.o: wiringPi.h wiringPiI2C.h bmp180.h -htu21d.o: wiringPi.h wiringPiI2C.h htu21d.h -ds18b20.o: wiringPi.h ds18b20.h -drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h -pseudoPins.o: wiringPi.h pseudoPins.h -wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h -wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h -wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h ads1115.h sn3218.h -wpiExtensions.o: drcSerial.h pseudoPins.h bmp180.h htu21d.h ds18b20.h -wpiExtensions.o: wpiExtensions.h diff --git a/FlippR-Driver/lib/wiringPi/ads1115.h b/FlippR-Driver/lib/wiringPi/ads1115.h deleted file mode 100644 index 5c91735..0000000 --- a/FlippR-Driver/lib/wiringPi/ads1115.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ads1115.c: - * Extend wiringPi with the ADS1115 I2C 16-bit ADC - * Copyright (c) 2016 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -// Constants for some of the internal functions - -// Gain - -#define ADS1115_GAIN_6 0 -#define ADS1115_GAIN_4 1 -#define ADS1115_GAIN_2 2 -#define ADS1115_GAIN_1 3 -#define ADS1115_GAIN_HALF 4 -#define ADS1115_GAIN_QUARTER 5 - -// Data rate - -#define ADS1115_DR_8 0 -#define ADS1115_DR_16 1 -#define ADS1115_DR_32 2 -#define ADS1115_DR_64 3 -#define ADS1115_DR_128 4 -#define ADS1115_DR_250 5 -#define ADS1115_DR_475 6 -#define ADS1115_DR_860 7 - -#ifdef __cplusplus -extern "C" { -#endif - -extern int ads1115Setup (int pinBase, int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/bmp180.h b/FlippR-Driver/lib/wiringPi/bmp180.h deleted file mode 100644 index 4a6d13a..0000000 --- a/FlippR-Driver/lib/wiringPi/bmp180.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * bmp180.h: - * Extend wiringPi with the BMP180 I2C Pressure and Temperature - * sensor. - * Copyright (c) 2016 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int bmp180Setup (const int pinBase) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/drcNet.h b/FlippR-Driver/lib/wiringPi/drcNet.h deleted file mode 100644 index 00f9b05..0000000 --- a/FlippR-Driver/lib/wiringPi/drcNet.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * drcNet.h: - * Extend wiringPi with the DRC Network protocol (e.g. to another Pi) - * Copyright (c) 2016-2017 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -/********* -struct drcNetStruct -{ - uint32_t pin ; - uint32_t cmd ; - uint32_t data ; -} ; -**************/ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int drcSetupNet (const int pinBase, const int numPins, const char *ipAddress, const char *port, const char *password) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/drcSerial.h b/FlippR-Driver/lib/wiringPi/drcSerial.h deleted file mode 100644 index 29e988e..0000000 --- a/FlippR-Driver/lib/wiringPi/drcSerial.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * drcSerial.h: - * Extend wiringPi with the DRC Serial protocol (e.g. to Arduino) - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/ds18b20.h b/FlippR-Driver/lib/wiringPi/ds18b20.h deleted file mode 100644 index a9ea291..0000000 --- a/FlippR-Driver/lib/wiringPi/ds18b20.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * bmp180.h: - * Extend wiringPi with the BMP180 I2C Pressure and Temperature - * sensor. - * Copyright (c) 2016 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int ds18b20Setup (const int pinBase, const char *serialNum) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/htu21d.h b/FlippR-Driver/lib/wiringPi/htu21d.h deleted file mode 100644 index 3965c54..0000000 --- a/FlippR-Driver/lib/wiringPi/htu21d.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * htu21d.h: - * Extend wiringPi with the HTU21D I2C Humidity and Temperature - * sensor. - * Copyright (c) 2016 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int htu21dSetup (const int pinBase) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/max31855.h b/FlippR-Driver/lib/wiringPi/max31855.h deleted file mode 100644 index 385c4bd..0000000 --- a/FlippR-Driver/lib/wiringPi/max31855.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * max31855.c: - * Extend wiringPi with the MAX31855 SPI Thermocouple driver - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int max31855Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/max5322.h b/FlippR-Driver/lib/wiringPi/max5322.h deleted file mode 100644 index a217cf8..0000000 --- a/FlippR-Driver/lib/wiringPi/max5322.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * max5322.h: - * Extend wiringPi with the MAX5322 SPI Digital to Analog convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int max5322Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23008.h b/FlippR-Driver/lib/wiringPi/mcp23008.h deleted file mode 100644 index e9299a8..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23008.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23008.h: - * Extend wiringPi with the MCP 23008 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23016.h b/FlippR-Driver/lib/wiringPi/mcp23016.h deleted file mode 100644 index f9b5cc5..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23016.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp23016.h: - * Extend wiringPi with the MCP 23016 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23016reg.h b/FlippR-Driver/lib/wiringPi/mcp23016reg.h deleted file mode 100644 index 9aea92d..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23016reg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * mcp23016: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23016 GPIO expander - * chip. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -// MCP23016 Registers - -#define MCP23016_GP0 0x00 -#define MCP23016_GP1 0x01 -#define MCP23016_OLAT0 0x02 -#define MCP23016_OLAT1 0x03 -#define MCP23016_IPOL0 0x04 -#define MCP23016_IPOL1 0x05 -#define MCP23016_IODIR0 0x06 -#define MCP23016_IODIR1 0x07 -#define MCP23016_INTCAP0 0x08 -#define MCP23016_INTCAP1 0x09 -#define MCP23016_IOCON0 0x0A -#define MCP23016_IOCON1 0x0B - -// Bits in the IOCON register - -#define IOCON_IARES 0x01 - -// Default initialisation mode - -#define IOCON_INIT 0 diff --git a/FlippR-Driver/lib/wiringPi/mcp23017.h b/FlippR-Driver/lib/wiringPi/mcp23017.h deleted file mode 100644 index 79b4d7b..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23017.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23017.h: - * Extend wiringPi with the MCP 23017 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23s08.h b/FlippR-Driver/lib/wiringPi/mcp23s08.h deleted file mode 100644 index ebf93d1..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23s08.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23s08.h: - * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23s17.h b/FlippR-Driver/lib/wiringPi/mcp23s17.h deleted file mode 100644 index 3b2a808..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23s17.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23s17.h: - * Extend wiringPi with the MCP 23s17 SPI GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp23x08.h b/FlippR-Driver/lib/wiringPi/mcp23x08.h deleted file mode 100644 index c4e6b27..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23x08.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * mcp23x17: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23x17 GPIO expander chip. - * This comes in 2 flavours: MCP23017 which has an I2C interface, - * an the MXP23S17 which has an SPI interface. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - - -// MCP23x17 Registers - -#define IODIRA 0x00 -#define IPOLA 0x02 -#define GPINTENA 0x04 -#define DEFVALA 0x06 -#define INTCONA 0x08 -#define IOCON 0x0A -#define GPPUA 0x0C -#define INTFA 0x0E -#define INTCAPA 0x10 -#define GPIOA 0x12 -#define OLATA 0x14 - -#define IODIRB 0x01 -#define IPOLB 0x03 -#define GPINTENB 0x05 -#define DEFVALB 0x07 -#define INTCONB 0x09 -#define IOCONB 0x0B -#define GPPUB 0x0D -#define INTFB 0x0F -#define INTCAPB 0x11 -#define GPIOB 0x13 -#define OLATB 0x15 - -// Bits in the IOCON register - -#define IOCON_UNUSED 0x01 -#define IOCON_INTPOL 0x02 -#define IOCON_ODR 0x04 -#define IOCON_HAEN 0x08 -#define IOCON_DISSLW 0x10 -#define IOCON_SEQOP 0x20 -#define IOCON_MIRROR 0x40 -#define IOCON_BANK_MODE 0x80 - -// Default initialisation mode - -#define IOCON_INIT (IOCON_SEQOP) - -// SPI Command codes - -#define CMD_WRITE 0x40 -#define CMD_READ 0x41 diff --git a/FlippR-Driver/lib/wiringPi/mcp23x0817.h b/FlippR-Driver/lib/wiringPi/mcp23x0817.h deleted file mode 100644 index 58bc038..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp23x0817.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * mcp23xxx: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23x08 and 17 GPIO expander - * chips. - * This comes in 2 flavours: MCP230xx (08/17) which has an I2C - * interface, and the MXP23Sxx (08/17) which has an SPI interface. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -// MCP23x08 Registers - -#define MCP23x08_IODIR 0x00 -#define MCP23x08_IPOL 0x01 -#define MCP23x08_GPINTEN 0x02 -#define MCP23x08_DEFVAL 0x03 -#define MCP23x08_INTCON 0x04 -#define MCP23x08_IOCON 0x05 -#define MCP23x08_GPPU 0x06 -#define MCP23x08_INTF 0x07 -#define MCP23x08_INTCAP 0x08 -#define MCP23x08_GPIO 0x09 -#define MCP23x08_OLAT 0x0A - -// MCP23x17 Registers - -#define MCP23x17_IODIRA 0x00 -#define MCP23x17_IPOLA 0x02 -#define MCP23x17_GPINTENA 0x04 -#define MCP23x17_DEFVALA 0x06 -#define MCP23x17_INTCONA 0x08 -#define MCP23x17_IOCON 0x0A -#define MCP23x17_GPPUA 0x0C -#define MCP23x17_INTFA 0x0E -#define MCP23x17_INTCAPA 0x10 -#define MCP23x17_GPIOA 0x12 -#define MCP23x17_OLATA 0x14 - -#define MCP23x17_IODIRB 0x01 -#define MCP23x17_IPOLB 0x03 -#define MCP23x17_GPINTENB 0x05 -#define MCP23x17_DEFVALB 0x07 -#define MCP23x17_INTCONB 0x09 -#define MCP23x17_IOCONB 0x0B -#define MCP23x17_GPPUB 0x0D -#define MCP23x17_INTFB 0x0F -#define MCP23x17_INTCAPB 0x11 -#define MCP23x17_GPIOB 0x13 -#define MCP23x17_OLATB 0x15 - -// Bits in the IOCON register - -#define IOCON_UNUSED 0x01 -#define IOCON_INTPOL 0x02 -#define IOCON_ODR 0x04 -#define IOCON_HAEN 0x08 -#define IOCON_DISSLW 0x10 -#define IOCON_SEQOP 0x20 -#define IOCON_MIRROR 0x40 -#define IOCON_BANK_MODE 0x80 - -// Default initialisation mode - -#define IOCON_INIT (IOCON_SEQOP) - -// SPI Command codes - -#define CMD_WRITE 0x40 -#define CMD_READ 0x41 diff --git a/FlippR-Driver/lib/wiringPi/mcp3002.h b/FlippR-Driver/lib/wiringPi/mcp3002.h deleted file mode 100644 index 0cd727f..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp3002.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp3002.c: - * Extend wiringPi with the MCP3002 SPI Analog to Digital convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3002Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp3004.h b/FlippR-Driver/lib/wiringPi/mcp3004.h deleted file mode 100644 index a07c0bf..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp3004.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp3004.c: - * Extend wiringPi with the MCP3004 SPI Analog to Digital convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3004Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp3422.h b/FlippR-Driver/lib/wiringPi/mcp3422.h deleted file mode 100644 index 72647d4..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp3422.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * mcp3422.h: - * Extend wiringPi with the MCP3422/3/4 I2C ADC chip - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#define MCP3422_SR_240 0 -#define MCP3422_SR_60 1 -#define MCP3422_SR_15 2 -#define MCP3422_SR_3_75 3 - -#define MCP3422_GAIN_1 0 -#define MCP3422_GAIN_2 1 -#define MCP3422_GAIN_4 2 -#define MCP3422_GAIN_8 3 - - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/mcp4802.h b/FlippR-Driver/lib/wiringPi/mcp4802.h deleted file mode 100644 index effa024..0000000 --- a/FlippR-Driver/lib/wiringPi/mcp4802.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp4802.c: - * Extend wiringPi with the MCP4802 SPI Digital to Analog convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp4802Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/pcf8574.h b/FlippR-Driver/lib/wiringPi/pcf8574.h deleted file mode 100644 index 8e2d818..0000000 --- a/FlippR-Driver/lib/wiringPi/pcf8574.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * pcf8574.h: - * Extend wiringPi with the PCF8574 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/pcf8591.h b/FlippR-Driver/lib/wiringPi/pcf8591.h deleted file mode 100644 index 6b44ccf..0000000 --- a/FlippR-Driver/lib/wiringPi/pcf8591.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * pcf8591.h: - * Extend wiringPi with the PCF8591 I2C GPIO Analog expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/pseudoPins.h b/FlippR-Driver/lib/wiringPi/pseudoPins.h deleted file mode 100644 index bef4660..0000000 --- a/FlippR-Driver/lib/wiringPi/pseudoPins.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * pseudoPins.h: - * Extend wiringPi with a number of pseudo pins which can be - * digitally or analog written/read. - * Copyright (c) 2012-2016 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -extern int pseudoPinsSetup (const int pinBase) ; diff --git a/FlippR-Driver/lib/wiringPi/rht03.h b/FlippR-Driver/lib/wiringPi/rht03.h deleted file mode 100644 index 9523fbf..0000000 --- a/FlippR-Driver/lib/wiringPi/rht03.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * rht03.h: - * Extend wiringPi with the rht03 Maxdetect 1-Wire sensor. - * Copyright (c) 2016-2017 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -extern int rht03Setup (const int pinBase, const int devicePin) ; diff --git a/FlippR-Driver/lib/wiringPi/sn3218.h b/FlippR-Driver/lib/wiringPi/sn3218.h deleted file mode 100644 index 580d5f9..0000000 --- a/FlippR-Driver/lib/wiringPi/sn3218.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * sn3218.c: - * Extend wiringPi with the SN3218 I2C LED driver board. - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int sn3218Setup (int pinBase) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/softPwm.h b/FlippR-Driver/lib/wiringPi/softPwm.h deleted file mode 100644 index 0351da5..0000000 --- a/FlippR-Driver/lib/wiringPi/softPwm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * softPwm.h: - * Provide 2 channels of software driven PWM. - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int softPwmCreate (int pin, int value, int range) ; -extern void softPwmWrite (int pin, int value) ; -extern void softPwmStop (int pin) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/softServo.h b/FlippR-Driver/lib/wiringPi/softServo.h deleted file mode 100644 index 794cf55..0000000 --- a/FlippR-Driver/lib/wiringPi/softServo.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * softServo.h: - * Provide N channels of software driven PWM suitable for RC - * servo motors. - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void softServoWrite (int pin, int value) ; -extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/softTone.h b/FlippR-Driver/lib/wiringPi/softTone.h deleted file mode 100644 index a93c5af..0000000 --- a/FlippR-Driver/lib/wiringPi/softTone.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * softTone.c: - * For that authentic retro sound... - * Er... A little experiment to produce tones out of a Pi using - * one (or 2) GPIO pins and a piezeo "speaker" element. - * (Or a high impedance speaker, but don'y blame me if you blow-up - * the GPIO pins!) - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int softToneCreate (int pin) ; -extern void softToneStop (int pin) ; -extern void softToneWrite (int pin, int freq) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/sr595.h b/FlippR-Driver/lib/wiringPi/sr595.h deleted file mode 100644 index 4a26dc7..0000000 --- a/FlippR-Driver/lib/wiringPi/sr595.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * sr595.h: - * Extend wiringPi with the 74x595 shift registers. - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int sr595Setup (const int pinBase, const int numPins, - const int dataPin, const int clockPin, const int latchPin) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/wiringPi.h b/FlippR-Driver/lib/wiringPi/wiringPi.h deleted file mode 100644 index f601f13..0000000 --- a/FlippR-Driver/lib/wiringPi/wiringPi.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * wiringPi.h: - * Arduino like Wiring library for the Raspberry Pi. - * Copyright (c) 2012-2017 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#ifndef __WIRING_PI_H__ -#define __WIRING_PI_H__ - -// C doesn't have true/false by default and I can never remember which -// way round they are, so ... -// (and yes, I know about stdbool.h but I like capitals for these and I'm old) - -#ifndef TRUE -# define TRUE (1==1) -# define FALSE (!TRUE) -#endif - -// GCC warning suppressor - -#define UNU __attribute__((unused)) - -// Mask for the bottom 64 pins which belong to the Raspberry Pi -// The others are available for the other devices - -#define PI_GPIO_MASK (0xFFFFFFC0) - -// Handy defines - -// wiringPi modes - -#define WPI_MODE_PINS 0 -#define WPI_MODE_GPIO 1 -#define WPI_MODE_GPIO_SYS 2 -#define WPI_MODE_PHYS 3 -#define WPI_MODE_PIFACE 4 -#define WPI_MODE_UNINITIALISED -1 - -// Pin modes - -#define INPUT 0 -#define OUTPUT 1 -#define PWM_OUTPUT 2 -#define GPIO_CLOCK 3 -#define SOFT_PWM_OUTPUT 4 -#define SOFT_TONE_OUTPUT 5 -#define PWM_TONE_OUTPUT 6 - -#define LOW 0 -#define HIGH 1 - -// Pull up/down/none - -#define PUD_OFF 0 -#define PUD_DOWN 1 -#define PUD_UP 2 - -// PWM - -#define PWM_MODE_MS 0 -#define PWM_MODE_BAL 1 - -// Interrupt levels - -#define INT_EDGE_SETUP 0 -#define INT_EDGE_FALLING 1 -#define INT_EDGE_RISING 2 -#define INT_EDGE_BOTH 3 - -// Pi model types and version numbers -// Intended for the GPIO program Use at your own risk. - -#define PI_MODEL_A 0 -#define PI_MODEL_B 1 -#define PI_MODEL_AP 2 -#define PI_MODEL_BP 3 -#define PI_MODEL_2 4 -#define PI_ALPHA 5 -#define PI_MODEL_CM 6 -#define PI_MODEL_07 7 -#define PI_MODEL_3 8 -#define PI_MODEL_ZERO 9 -#define PI_MODEL_CM3 10 -#define PI_MODEL_ZERO_W 12 - -#define PI_VERSION_1 0 -#define PI_VERSION_1_1 1 -#define PI_VERSION_1_2 2 -#define PI_VERSION_2 3 - -#define PI_MAKER_SONY 0 -#define PI_MAKER_EGOMAN 1 -#define PI_MAKER_EMBEST 2 -#define PI_MAKER_UNKNOWN 3 - -extern const char *piModelNames [16] ; -extern const char *piRevisionNames [16] ; -extern const char *piMakerNames [16] ; -extern const int piMemorySize [ 8] ; - - -// Intended for the GPIO program Use at your own risk. - -// Threads - -#define PI_THREAD(X) void *X (UNU void *dummy) - -// Failure modes - -#define WPI_FATAL (1==1) -#define WPI_ALMOST (1==2) - - -// wiringPiNodeStruct: -// This describes additional device nodes in the extended wiringPi -// 2.0 scheme of things. -// It's a simple linked list for now, but will hopefully migrate to -// a binary tree for efficiency reasons - but then again, the chances -// of more than 1 or 2 devices being added are fairly slim, so who -// knows.... - -struct wiringPiNodeStruct -{ - int pinBase ; - int pinMax ; - - int fd ; // Node specific - unsigned int data0 ; // ditto - unsigned int data1 ; // ditto - unsigned int data2 ; // ditto - unsigned int data3 ; // ditto - - void (*pinMode) (struct wiringPiNodeStruct *node, int pin, int mode) ; - void (*pullUpDnControl) (struct wiringPiNodeStruct *node, int pin, int mode) ; - int (*digitalRead) (struct wiringPiNodeStruct *node, int pin) ; -//unsigned int (*digitalRead8) (struct wiringPiNodeStruct *node, int pin) ; - void (*digitalWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; -// void (*digitalWrite8) (struct wiringPiNodeStruct *node, int pin, int value) ; - void (*pwmWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; - int (*analogRead) (struct wiringPiNodeStruct *node, int pin) ; - void (*analogWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; - - struct wiringPiNodeStruct *next ; -} ; - -extern struct wiringPiNodeStruct *wiringPiNodes ; - - -// Function prototypes -// c++ wrappers thanks to a comment by Nick Lott -// (and others on the Raspberry Pi forums) - -#ifdef __cplusplus -extern "C" { -#endif - -// Data - -// Internal - -extern int wiringPiFailure (int fatal, const char *message, ...) ; - -// Core wiringPi functions - -extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ; -extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; - -extern void wiringPiVersion (int *major, int *minor) ; -extern int wiringPiSetup (void) ; -extern int wiringPiSetupSys (void) ; -extern int wiringPiSetupGpio (void) ; -extern int wiringPiSetupPhys (void) ; - -extern void pinModeAlt (int pin, int mode) ; -extern void pinMode (int pin, int mode) ; -extern void pullUpDnControl (int pin, int pud) ; -extern int digitalRead (int pin) ; -extern void digitalWrite (int pin, int value) ; -extern unsigned int digitalRead8 (int pin) ; -extern void digitalWrite8 (int pin, int value) ; -extern void pwmWrite (int pin, int value) ; -extern int analogRead (int pin) ; -extern void analogWrite (int pin, int value) ; - -// PiFace specifics -// (Deprecated) - -extern int wiringPiSetupPiFace (void) ; -extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only - -// On-Board Raspberry Pi hardware specific stuff - -extern int piGpioLayout (void) ; -extern int piBoardRev (void) ; // Deprecated -extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ; -extern int wpiPinToGpio (int wpiPin) ; -extern int physPinToGpio (int physPin) ; -extern void setPadDrive (int group, int value) ; -extern int getAlt (int pin) ; -extern void pwmToneWrite (int pin, int freq) ; -extern void pwmSetMode (int mode) ; -extern void pwmSetRange (unsigned int range) ; -extern void pwmSetClock (int divisor) ; -extern void gpioClockSet (int pin, int freq) ; -extern unsigned int digitalReadByte (void) ; -extern unsigned int digitalReadByte2 (void) ; -extern void digitalWriteByte (int value) ; -extern void digitalWriteByte2 (int value) ; - -// Interrupts -// (Also Pi hardware specific) - -extern int waitForInterrupt (int pin, int mS) ; -extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; - -// Threads - -extern int piThreadCreate (void *(*fn)(void *)) ; -extern void piLock (int key) ; -extern void piUnlock (int key) ; - -// Schedulling priority - -extern int piHiPri (const int pri) ; - -// Extras from arduino land - -extern void delay (unsigned int howLong) ; -extern void delayMicroseconds (unsigned int howLong) ; -extern unsigned int millis (void) ; -extern unsigned int micros (void) ; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/FlippR-Driver/lib/wiringPi/wiringPiI2C.h b/FlippR-Driver/lib/wiringPi/wiringPiI2C.h deleted file mode 100644 index 6db8c68..0000000 --- a/FlippR-Driver/lib/wiringPi/wiringPiI2C.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * wiringPiI2C.h: - * Simplified I2C access routines - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int wiringPiI2CRead (int fd) ; -extern int wiringPiI2CReadReg8 (int fd, int reg) ; -extern int wiringPiI2CReadReg16 (int fd, int reg) ; - -extern int wiringPiI2CWrite (int fd, int data) ; -extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; -extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; - -extern int wiringPiI2CSetupInterface (const char *device, int devId) ; -extern int wiringPiI2CSetup (const int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/wiringPiSPI.h b/FlippR-Driver/lib/wiringPi/wiringPiSPI.h deleted file mode 100644 index 3980321..0000000 --- a/FlippR-Driver/lib/wiringPi/wiringPiSPI.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * wiringPiSPI.h: - * Simplified SPI access routines - * Copyright (c) 2012-2015 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -int wiringPiSPIGetFd (int channel) ; -int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; -int wiringPiSPISetupMode (int channel, int speed, int mode) ; -int wiringPiSPISetup (int channel, int speed) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/wiringSerial.h b/FlippR-Driver/lib/wiringPi/wiringSerial.h deleted file mode 100644 index 430dc73..0000000 --- a/FlippR-Driver/lib/wiringPi/wiringSerial.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * wiringSerial.h: - * Handle a serial port - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int serialOpen (const char *device, const int baud) ; -extern void serialClose (const int fd) ; -extern void serialFlush (const int fd) ; -extern void serialPutchar (const int fd, const unsigned char c) ; -extern void serialPuts (const int fd, const char *s) ; -extern void serialPrintf (const int fd, const char *message, ...) ; -extern int serialDataAvail (const int fd) ; -extern int serialGetchar (const int fd) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/wiringShift.h b/FlippR-Driver/lib/wiringPi/wiringShift.h deleted file mode 100644 index 419ade4..0000000 --- a/FlippR-Driver/lib/wiringPi/wiringShift.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * wiringShift.h: - * Emulate some of the Arduino wiring functionality. - * - * Copyright (c) 2009-2012 Gordon Henderson. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#define LSBFIRST 0 -#define MSBFIRST 1 - -#ifndef _STDINT_H -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ; -extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ; - -#ifdef __cplusplus -} -#endif diff --git a/FlippR-Driver/lib/wiringPi/wpiExtensions.h b/FlippR-Driver/lib/wiringPi/wpiExtensions.h deleted file mode 100644 index fcaec96..0000000 --- a/FlippR-Driver/lib/wiringPi/wpiExtensions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * extensions.h: - * Part of the GPIO program to test, peek, poke and otherwise - * noodle with the GPIO hardware on the Raspberry Pi. - * Copyright (c) 2012-2015 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - - -extern int loadWPiExtension (char *progName, char *extensionData, int verbose) ; diff --git a/FlippR-Driver/networking/CMakeLists.txt b/FlippR-Driver/networking/CMakeLists.txt index b06a041..a67d5cb 100644 --- a/FlippR-Driver/networking/CMakeLists.txt +++ b/FlippR-Driver/networking/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.6.2) project(flippR_driver_networking) -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cli/networking) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/networking) set(SOURCES input/InputSocketHandler.cpp output/OutputRequestHandler.cpp diff --git a/FlippR-Driver/networking/FlippRServer.cpp b/FlippR-Driver/networking/FlippRServer.cpp index 9b70795..8ba7583 100644 --- a/FlippR-Driver/networking/FlippRServer.cpp +++ b/FlippR-Driver/networking/FlippRServer.cpp @@ -16,6 +16,8 @@ #include #include +#include +#include int main(int argc, char** argv) { @@ -37,16 +39,8 @@ using namespace Poco; FlippRServer::FlippRServer() : help_requested(false), input_port(9980), - output_port(9981), - input_config("Not set"), - matrix_config("Not set"), - lamp_config("Not set"), - solenoid_config("Not set"), - sound_config("Not set"), - display_config("Not set") -{ - this->parse_server_config_file(); -} + output_port(9981) +{} void FlippRServer::parse_server_config_file() { @@ -57,46 +51,69 @@ void FlippRServer::parse_server_config_file() try { - config.open("./server_config.json"); + config.open(this->server_config); } catch(const std::exception e) { - logger().information(FCYN("server_config.json not specified!")); - return; + logger().error(FCYN("server_config.json not specified!")); + exit(Application::EXIT_USAGE); } try { - json = parser.parse(config).extract(); + auto parse = parser.parse(config); + json = parse.extract(); } catch(const std::exception e) { - logger().information(FRED("server_config.json not readable!")); - return; + logger().error(e.what()); + exit(Application::EXIT_IOERR); } logger().information(FCYN("Parsing server_config.json...")); - for(auto &config_json : json->getNames()) + Object::NameList keys = json->getNames(); + std::sort(keys.begin(), keys.end()); + + if(!std::includes(keys.begin(), keys.end(), REQUIRED_CONFIG_KEYS.begin(), REQUIRED_CONFIG_KEYS.end())) { - handle_config_file(config_json, json->get(config_json)); + std::string config_keys; + config_keys = std::accumulate(REQUIRED_CONFIG_KEYS.begin(), REQUIRED_CONFIG_KEYS.end(), config_keys); + logger().error("Need all of the following keys to be specified in server_config json" + config_keys); + Application::EXIT_USAGE; } + this->configs = *json; + config.close(); } +void FlippRServer::uninitialize() +{ + this->output_driver->deactivate_all_lamps(); + this->output_driver->deactivate_displays(); + this->output_server->stop(); + + ServerApplication::uninitialize(); +} + /** * Initially called before main. */ void FlippRServer::initialize(Application &self) { + this->parse_server_config_file(); //Todo May restructure with subsystems //make this one application and subsystems ServerApplications - this->initialize_output_driver(); this->initialize_input_driver(); + this->output_server = std::unique_ptr(this->build_output_server()); + this->output_server->start(); + + this->input_server = std::unique_ptr(this->build_input_server()); + //https://gist.github.com/NIPE-SYSTEMS/5a06428c0880ed7ff3cc4304be436e3e ServerApplication::initialize(self); } @@ -110,10 +127,10 @@ void FlippRServer::initialize_output_driver() try { - lamp_config_stream.open(this->lamp_config); - solenoid_config_stream.open(this->solenoid_config); - sound_config_stream.open(this->sound_config); - display_config_stream.open(this->display_config); + lamp_config_stream.open(this->configs["lamp-config"].toString()); + solenoid_config_stream.open(this->configs["solenoid-config"].toString()); + sound_config_stream.open(this->configs["sound-config"].toString()); + display_config_stream.open(this->configs["display-config"].toString()); } catch(const std::exception& e) { @@ -134,8 +151,8 @@ void FlippRServer::initialize_input_driver() try { - input_config_stream.open(this->input_config); - matrix_config_stream.open(this->matrix_config); + input_config_stream.open(this->configs["input-config"].toString()); + matrix_config_stream.open(this->configs["matrix-config"].toString()); } catch(const std::exception& e) { @@ -148,22 +165,13 @@ void FlippRServer::initialize_input_driver() int FlippRServer::main(const std::vector& args) { - if(help_requested) - return Application::EXIT_OK; - - std::unique_ptr output_server(this->build_output_server()); - output_server->start(); - - std::unique_ptr input_server(this->build_input_server()); - - logger().information("Server running!"); - - waitForTerminationRequest(); - this->output_driver->deactivate_all_lamps(); - this->output_driver->deactivate_displays(); - output_server->stop(); - + if(!help_requested) + { + logger().information("Server running!"); + waitForTerminationRequest(); + } return Application::EXIT_OK; + } HTTPServer* FlippRServer::build_output_server() @@ -189,24 +197,22 @@ TCPServer* FlippRServer::build_input_server() return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), port); } - - void FlippRServer::defineOptions(OptionSet& options) { ServerApplication::defineOptions(options); options.addOption( - Option("help", "h", "display argument help information") + Option("help", "h", "display this help") .required(false) .repeatable(false) .callback(OptionCallback( this, &FlippRServer::handle_help))); options.addOption(Option("input-port", "i", "Define the port for the TCP-Input-Server, which represents the flipper inputs. Default 9980") - .required(false) - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("input-port", true)); + .required(false) + .repeatable(false) + .callback(OptionCallback(this, &FlippRServer::handle_config_file)) + .argument("input-port", true)); options.addOption(Option("output-port", "o", "Define the port for the HTTP-Output-Server, which represents the flipper outputs. Default 9981") .required(false) @@ -214,61 +220,21 @@ void FlippRServer::defineOptions(OptionSet& options) .callback(OptionCallback(this, &FlippRServer::handle_config_file)) .argument("output-port", true)); - options.addOption(Option("input-config", "I", "Specify where the input-config file is located. Only needed when not in this folder.") - .required(this->input_config == "Not set") + options.addOption(Option("server-config", "s", "Specify where the server-config file with paths to the other configs is located. Only needed when not in this folder.") + .required(true) .repeatable(false) .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("input-config", true)); - - options.addOption(Option("matrix-config", "M", "Specify where the matrix-config file is located. Only needed when not in this folder.") - .required(this->matrix_config == "Not set") - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("matric-config", true)); - - options.addOption(Option("lamp-config", "L", "Specify where the lamp-config file is located. Only needed when not in this folder.") - .required(this->lamp_config == "Not set") - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("lamp-config", true)); - - options.addOption(Option("solenoid-config", "N", "Specify where the solenoid-config file is located. Only needed when not in this folder.") - .required(this->solenoid_config == "Not set") - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("solenoid-config", true)); - - options.addOption(Option("sound-config", "S", "Specify where the sound-config file is located. Only needed when not in this folder.") - .required(this->sound_config == "Not set") - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("sound-config", true)); - - options.addOption(Option("display-config", "D", "Specify where the display-config file is located. Only needed when not in this folder.") - .required(this->display_config == "Not set") - .repeatable(false) - .callback(OptionCallback(this, &FlippRServer::handle_config_file)) - .argument("display-config", true)); + .argument("server-config", true)); } void FlippRServer::handle_config_file(const std::string &name, const std::string &value) { - if(name == "input-config") - this->input_config = value; - else if(name == "matrix-config") - this->matrix_config = value; - else if(name == "lamp-config") - this->lamp_config = value; - else if(name == "solenoid-config") - this->solenoid_config = value; - else if(name == "sound-config") - this->sound_config = value; - else if(name == "display-config") - this->display_config = value; - else if(name == "input-port") + if(name == "input-port") this->input_port = std::stoi(value); else if(name == "output-port") this->output_port = std::stoi(value); + else if(name == "server-config") + this->server_config = value; else { logger().information("Configuration \"" + name + "\" is not known."); @@ -283,9 +249,7 @@ void FlippRServer::handle_help(const std::string& name, const std::string& value helpFormatter.setCommand(commandName()); helpFormatter.setUsage("OPTIONS"); helpFormatter.setHeader( - "The FlippR-Server, appropriate config-files must either be located in the actual folder\ - or the paths must be specified by commandline options. \ - The config file paths as well as the port settings can be specified in a a file server_config.json"); + "The FlippR-Server, one must specify a json with all needed config files."); helpFormatter.format(std::cout); stopOptionsProcessing(); help_requested = true; @@ -298,6 +262,8 @@ std::string FlippRServer::get_runtime_dir() { runtime_dir = DEFAULT_RUNTIME_DIR; } + + return runtime_dir; } } diff --git a/FlippR-Driver/networking/FlippRServer.h b/FlippR-Driver/networking/FlippRServer.h index 743262b..a34706f 100644 --- a/FlippR-Driver/networking/FlippRServer.h +++ b/FlippR-Driver/networking/FlippRServer.h @@ -10,6 +10,7 @@ #include #include +#include namespace flippR_driver { @@ -24,6 +25,7 @@ public: int main(const std::vector& args); void initialize(Poco::Util::Application& self); + void uninitialize(); void defineOptions(Poco::Util::OptionSet& options); void handle_help(const std::string &name, const std::string &port); @@ -38,24 +40,26 @@ private: Poco::Net::HTTPServer* build_output_server(); Poco::Net::TCPServer* build_input_server(); - private: const std::string DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/"; const std::string SOCKET_NAME = "S.flippR_driver"; + const std::vector REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config", + "matrix-config", "solenoid-config", "sound-config"}; int input_port; int output_port; bool help_requested; - std::string input_config; - std::string matrix_config; - std::string lamp_config; - std::string solenoid_config; - std::string sound_config; - std::string display_config; + Poco::DynamicStruct configs; + + std::string server_config; std::shared_ptr input_driver; std::shared_ptr output_driver; + + std::unique_ptr output_server; + std::unique_ptr input_server; + }; }; diff --git a/FlippR-Driver/networking/output/OutputRequestHandler.cpp.autosave b/FlippR-Driver/networking/output/OutputRequestHandler.cpp.autosave new file mode 100644 index 0000000..06bd662 --- /dev/null +++ b/FlippR-Driver/networking/output/OutputRequestHandler.cpp.autosave @@ -0,0 +1,261 @@ +// +// Created by rhetenor on 3/6/19. +// + + +#include +#include +#include + +#include + +#include "OutputRequestHandler.h" + +namespace flippR_driver +{ +namespace networking +{ + +using namespace Poco; +using namespace Poco::Net; + +OutputRequestHandler::OutputRequestHandler(std::shared_ptr output_driver) : + output_driver(output_driver) + {} + + /** + * Handles a REST request with a URI form of: + * + * address/{item_type}/[item_name]/[action]/[score] + * + * Where + * {item_type} is either solenoids, lamps, sounds, displays, or one of the two special events: activate and deactivate + * [item_name] is the string name of an item (optional if you want to get the list of all available items) + * [action] is the particular action for the item: + * solenoids: trigger + * lamps: activate, deactivate, status + * sounds: play + * displays: write_score (for this is the additional optional attribute [score] + * + * @param request + * @param response + */ +void OutputRequestHandler::handleRequest(HTTPServerRequest &request, + HTTPServerResponse &response) +{ + auto path_segments = getPathSegments(URI(request.getURI())); + + // fill up vector + for(int i = path_segments.size(); i < 4; i++) + { + path_segments.emplace_back(""); + } + + std::string item_type = path_segments.at(0); + std::string item_name = path_segments.at(1); + std::string action = path_segments.at(2); + std::string score = path_segments.at(3); + + if(item_type == "deactivate") + { + this->output_driver->deactivate_displays(); + this->output_driver->deactivate_all_lamps(); + return; + } + + if(item_type == "activate") + { + this->output_driver->activate_displays(); + return; + } + + response.setContentType("text/json"); + response.setStatus(HTTPServerResponse::HTTP_OK); + + try + { + boost::optional json_response = parseRequest(item_type, item_name, action, score); + if(json_response) + { + std::ostream& ostr = response.send(); + json_response->stringify(ostr); + } + } + catch(const NotFoundException &e) + { + response.setStatusAndReason(HTTPServerResponse::HTTP_NOT_FOUND, e.displayText()); + } + catch(const Poco::InvalidArgumentException &e) + { + response.setStatusAndReason(HTTPServerResponse::HTTP_BAD_REQUEST, e.displayText()); + } +} + +boost::optional OutputRequestHandler::parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score) +{ + if(item_type == "solenoids") + { + return parseSolenoid(item_name, action); + } + else if(item_type == "lamps") + { + return parseLamp(item_name, action); + } + else if(item_type == "sounds") + { + return parseSound(item_name, action); + } + else if(item_type == "displays") + { + return parseDisplay(item_name, action, score); + } + else + { + throw new Poco::NotFoundException("No item type called " + item_type); + } +} + +boost::optional OutputRequestHandler::parseSolenoid(const std::string& item_name, const std::string& action) +{ + if(item_name == "") + { + Poco::JSON::Object response; + response.set("solenoids", this->output_driver->get_solenoids()); + return response; + } + + auto opt_solenoid = this->output_driver->get_solenoid(item_name); + + if(!opt_solenoid) + { + throw new Poco::NotFoundException("No solenoid with name \"" + item_name + "\"!"); + } + + auto solenoid = opt_solenoid->get(); + + if(action == "trigger") + { + solenoid->trigger(); + } + else + { + throw new Poco::NotFoundException("No action with name \"" + action + "\" on solenoids!"); + } + + return {}; +} + +boost::optional OutputRequestHandler::parseLamp(const std::string& item_name, const std::string& action) +{ + if(item_name == "") + { + Poco::JSON::Object response; + response.set("lamps", this->output_driver->get_lamps()); + return response; + } + + auto opt_lamp = this->output_driver->get_lamp(item_name); + + if(!opt_lamp) + { + throw new Poco::NotFoundException("No lamp with name \"" + item_name + "\"!"); + } + + auto lamp = opt_lamp->get(); + + if(action == "activate") + { + lamp->activate(); + } + else if(action == "deactivate") + { + lamp->deactivate(); + } + else + { + throw new Poco::NotFoundException("No action with name \"" + action + "\" on lamps!"); + } + + return {}; +} + +boost::optional OutputRequestHandler::parseSound(const std::string& item_name, const std::string& action) +{ + if(item_name == "") + { + Poco::JSON::Object response; + response.set("sounds", this->output_driver->get_sounds()); + return response; + } + + auto opt_sound = this->output_driver->get_sound(item_name); + + if(!opt_sound) + { + throw new Poco::NotFoundException("No sound with name \"" + item_name + "\"!"); + } + + auto sound = opt_sound->get(); + + if(action == "play") + { + sound->play(); + } + else + { + throw new Poco::NotFoundException("No action with name \"" + action + "\" on sounds!"); + } + + return {}; +} + +boost::optional OutputRequestHandler::parseDisplay(const std::string& item_name, const std::string& action, const std::string& score) +{ + if(item_name == "") + { + Poco::JSON::Object response; + response.set("displays", this->output_driver->get_displays()); + return response; + } + + uint8_t display_number = std::stoi(item_name); + auto opt_display = this->output_driver->get_display(display_number); + + if(!opt_display) + { + throw new Poco::NotFoundException("No display with number \"" + item_name + "\"!"); + } + + auto display = opt_display->get(); + + + if(action == "write_score") + { + try + { + unsigned int numerical_score = std::stoi(score); + display->write_score(numerical_score); + } + catch(std::invalid_argument &e) + { + throw new Poco::InvalidArgumentException("Could not convert " + score + " to a number!\n" + e.what()); + } + } + else + { + throw new Poco::NotFoundException("No Action with name \"" + action + "\" on sounds!"); + } + + return {}; +} + +std::vector OutputRequestHandler::getPathSegments(Poco::URI uri) +{ + std::vector path_segments; + uri.getPathSegments(path_segments); + return path_segments; +} + +} +} + diff --git a/FlippR-Driver/src/PinController.cpp b/FlippR-Driver/src/PinController.cpp index fe1146a..fce8629 100644 --- a/FlippR-Driver/src/PinController.cpp +++ b/FlippR-Driver/src/PinController.cpp @@ -8,13 +8,10 @@ #include "PinController.h" #include "utility/config.h" -#define NOT_PI -#ifndef NOT_PI -#include "wiringPi/wiringPi.h" -#include "wiringPi/mcp23017.h" -#endif - -#ifdef NOT_PI +#ifndef NO_WIRING_PI +#include +#include +#else #include "utility/wiringPiTesting.hpp" #endif diff --git a/FlippR-Driver/src/output/detail/DriverBoardPinController.cpp b/FlippR-Driver/src/output/detail/DriverBoardPinController.cpp index 2a9215d..1b03e6f 100644 --- a/FlippR-Driver/src/output/detail/DriverBoardPinController.cpp +++ b/FlippR-Driver/src/output/detail/DriverBoardPinController.cpp @@ -18,7 +18,6 @@ namespace detail DriverBoardPinController::DriverBoardPinController(std::shared_ptr output_item_mutex) : output_item_mutex(std::move(output_item_mutex)) { - CLOG(INFO, OUTPUT_LOGGER) << "Created DriverBoardPinController."; }