diff --git a/CMakeLists.txt b/CMakeLists.txt index 26623536..e5349629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,7 @@ set (C_CXX_WARNING_FLAGS -Wall -Wno-misleading-indentation -Wno-strict-aliasing) # Warnings as errors? if (WERROR) - set (C_CXX_WARNING_FLAGS "-Werror ${C_CXX_WARNING_FLAGS}") + list (APPEND C_CXX_WARNING_FLAGS -Werror) message (STATUS "Warnings as errors enabled (-Werror), disable with -DWERROR=off") endif (WERROR) @@ -113,6 +113,11 @@ upm_add_compile_flags(CXX ${C_CXX_WARNING_FLAGS} -Woverloaded-virtual -Wreorder) +# Allow exception error handling for Android C++ +if (ANDROID) + upm_add_compile_flags(CXX -fexceptions) +endif (ANDROID) + find_package (Threads REQUIRED) find_package (PkgConfig REQUIRED) @@ -121,7 +126,13 @@ unset(MRAA_FOUND CACHE) set(MRAA_MINIMUM 1.6.1) pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM}) # Also, get full path to the mraa library -find_library(MRAA_LIBRARY NAMES mraa PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH) +find_library(MRAA_LIBRARY NAMES mraa PATHS ${MRAA_LIBDIR}) + +# Test MRAA for various compile options +include (CheckLibraryExists) +check_library_exists (${MRAA_LIBRARIES} mraa_iio_init "${MRAA_LIBDIR}" MRAA_IIO_FOUND) +check_library_exists (${MRAA_LIBRARIES} mraa_firmata_init "${MRAA_LIBDIR}" MRAA_FIRMATA_FOUND) +check_library_exists (${MRAA_LIBRARIES} mraa_uart_ow_init "${MRAA_LIBDIR}" MRAA_OW_FOUND) # Check for BACNET pkg_check_modules (BACNET libbacnet) @@ -146,7 +157,7 @@ if (BUILDSWIGJAVA) find_package (JNI REQUIRED) pkg_check_modules (MRAAJAVA REQUIRED mraajava>=0.8.0) # Also, get full path to the mraajava library - find_library(MRAAJAVA_LIBRARY NAMES mraajava PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH) + find_library(MRAAJAVA_LIBRARY NAMES mraajava PATHS ${MRAA_LIBDIR}) endif (BUILDSWIGJAVA) # Find swig if any wrapper is enabled @@ -415,12 +426,10 @@ if (RPM) endif() # UPM common headers -set (UPM_COMMON_HEADER_DIRS - ${CMAKE_HOME_DIRECTORY}/include - ${CMAKE_HOME_DIRECTORY}/include/fti - ${CMAKE_BINARY_DIR}/src) +set (UPM_COMMON_HEADER_DIRS ${CMAKE_HOME_DIRECTORY}/include) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/src/version.hpp @ONLY) +# Generate a build-only C++ header to add functionality to SWIG'ed modules +configure_file (${PROJECT_SOURCE_DIR}/cmake/modules/version.hpp.in ${PROJECT_BINARY_DIR}/src/version.hpp @ONLY) # UPM source add_subdirectory (src) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bacf65d1..f4b1c498 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -50,6 +50,11 @@ function (add_example example_src) # Parse function parameters cmake_parse_arguments(add_example "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # Attempt to remove this example source file from a list of example + # sources. This allows for handling special case examples. + list (REMOVE_ITEM example_src_list ${example_src}) + set (example_src_list ${example_src_list} PARENT_SCOPE) + # Get the base filename from the full filename # For file /some/path/to/sensorfoo-bar.c, example_name = sensorfoo-bar get_filename_component(example_name ${example_src} NAME_WE) @@ -84,7 +89,7 @@ function (add_example example_src) # If a dependency target does NOT exist, print a warning and skip foreach(_dep_target ${lib_target_names}) if (NOT TARGET ${_dep_target}) - message(STATUS "Missing CMake target (${_dep_target}), skipping example ${example_src}") + message(STATUS "Example ${example_src} is missing a required CMake target (${_dep_target}), skipping...") return() endif () endforeach () @@ -96,10 +101,6 @@ function (add_example example_src) foreach(_dep_target ${lib_target_names}) target_link_libraries(${this_target_name} ${_dep_target} ${CMAKE_THREAD_LIBS_INIT}) endforeach () - - # Special case... - list (REMOVE_ITEM example_src_list ${example_src}) - set (example_src_list ${example_src_list} PARENT_SCOPE) endfunction (add_example example_src) # Add subdirectories if BUILDEXAMPLES=on diff --git a/examples/c++/jhd1313m1-lcd.cxx b/examples/c++/jhd1313m1-lcd.cxx index 9e29e830..9bbe26d7 100644 --- a/examples/c++/jhd1313m1-lcd.cxx +++ b/examples/c++/jhd1313m1-lcd.cxx @@ -23,7 +23,10 @@ */ #include +#include + #include "jhd1313m1.hpp" +#include "upm_utilities.h" int shouldRun = true; @@ -64,7 +67,7 @@ main(int argc, char **argv) // Echo via printf printf("Hello World %d rgb: 0x%02x%02x%02x\n", ndx++, r, g, b); - sleep(1); + upm_delay(1); } //! [Interesting] diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index fe5e98fb..2cd46458 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -7,5 +7,5 @@ file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") # - Create an executable for all other src files in this directory ------------- foreach (_example_src ${example_src_list}) - add_example(${_example_src} SUFFIX "-c") + add_example(${_example_src} TARGETS utilities-c SUFFIX "-c") endforeach () diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index aa9e55c1..a6cf79a9 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -111,7 +111,9 @@ add_example(RotaryEncoderSample rotaryencoder) add_example(RPR220_intrSample rpr220) add_example(RPR220Sample rpr220) add_example(ST7735Sample st7735) -add_example(StepMotorSample stepmotor) +if (NOT ANDROID) + add_example(StepMotorSample stepmotor) +endif () add_example(TM1637Sample tm1637) add_example(TP401Sample gas) add_example(TSL2561Sample tsl2561) @@ -145,7 +147,9 @@ if (BACNET_FOUND) add_example(T8100_Example t8100) add_example(TB7300_Example tb7300) endif() -add_example(VCAP_Example vcap) +if (JPEG_FOUND) + add_example(VCAP_Example vcap) +endif() add_example(BMP280_Example bmp280) add_example(BNO055_Example bno055) add_example(BMX055_Example bmx055) diff --git a/examples/java/MPU9150Sample.java b/examples/java/MPU9150Sample.java index a8de875a..f3a1a97a 100644 --- a/examples/java/MPU9150Sample.java +++ b/examples/java/MPU9150Sample.java @@ -34,13 +34,14 @@ public class MPU9150Sample { while (true) { sensor.update(); - float[] accel = sensor.getAccelerometer(); - System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " - + accel[2]); - - float[] gyro = sensor.getGyroscope(); - System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " - + gyro[2]); +// These don't exist +// float[] accel = sensor.getAccelerometer(); +// System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " +// + accel[2]); +// +// float[] gyro = sensor.getGyroscope(); +// System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " +// + gyro[2]); float[] magn = sensor.getMagnetometer(); System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: " @@ -50,4 +51,4 @@ public class MPU9150Sample { } // ! [Interesting] } -} \ No newline at end of file +} diff --git a/include/upm_fti.h b/include/upm_fti.h index 1e7d9018..0d907d9a 100644 --- a/include/upm_fti.h +++ b/include/upm_fti.h @@ -26,6 +26,8 @@ #ifndef UPM_FTI_H_ #define UPM_FTI_H_ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27131355..fefe358a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,11 @@ set (SWIG_CXX_DISABLE_WARNINGS -Wno-error -Wno-maybe-uninitialized -Wno-strict-aliasing) +# If building under android, make sure swig gets an ANDROID flag +if (ANDROID) + list (APPEND CMAKE_SWIG_FLAGS -DANDROID) +endif (ANDROID) + macro (file_to_list readfile outlist) FILE(READ "${readfile}" contents) STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}") @@ -37,32 +42,60 @@ macro (upm_create_install_pkgconfig generated_file install_location) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location}) endmacro(upm_create_install_pkgconfig) -# This function iterates over all target names stored in CACHE variable -# UPM_LIBRARY_TARGETS and writes a .pc file to each build directory -function (_gen_pkg_config_per_target) - list(LENGTH UPM_LIBRARY_TARGETS n_targets) - message(STATUS "Generating pkg-config files for ${n_targets} libraries...") - set (n_ctargets 0) - set (n_cxxtargets 0) +# Given a target name, return all in-project targets ALREADY defined (ie, this +# does not comprehend targets that have yet to be added. +function (_get_dependency_targets target return_variable) + # Clear the variable + set(${return_variable} "") + + # Get the LINK_LIBRARIES property of the target + get_target_property(_dep_libs ${target} LINK_LIBRARIES) + + # Remove this libname from the _dep_libs (if it exists) + list(REMOVE_ITEM _dep_libs ${libname}) + + # Check if any of the LINK_LIBRARIES are targets in this project, + # if so, add them to ${return_variable} + foreach (deplib ${_dep_libs}) + # Only add targets that exist + if (TARGET ${deplib}) + list(APPEND ${return_variable} ${deplib}) + # Special case - mraa is NOT in this project, but add it to the + # reqlibname list (used in various items like pom files, .pc files, etc + elseif (${deplib} MATCHES mraa) + list(APPEND ${return_variable} mraa) + endif (TARGET ${deplib}) + endforeach (deplib ${_dep_libs}) + # Uniquify + list(REMOVE_DUPLICATES ${return_variable}) + # Make the list available outside this function + set (${return_variable} ${${return_variable}} PARENT_SCOPE) +endfunction (_get_dependency_targets target) + +# This function iterates over all provided target names and +# writes a .pc file to each build directory +function (_gen_pkg_config_per_target LABEL) + list(LENGTH ARGN n_targets) + message(STATUS "Generating pkg-config files for ${n_targets} ${LABEL} libraries...") # Iterate over the targets an build package config (.pc) files - foreach (target ${UPM_LIBRARY_TARGETS}) + foreach (target ${ARGN}) if (TARGET ${target}) get_target_property(libname ${target} PKG_CONFIG_NAME) get_target_property(libdescription ${target} PKG_CONFIG_DESCRIPTION) get_target_property(reqlibname ${target} PKG_EXT_REQ_LIBS) get_target_property(BINARY_DIR ${target} BINARY_DIR) - get_target_property(DEPLIBS ${target} LINK_LIBRARIES) - # Remove this libname from the DEPLIBS (if it's there) - list(REMOVE_ITEM DEPLIBS ${libname}) + + # Get a list of in-project dependency targets for this target + _get_dependency_targets(${target} DEPLIBS) + # Check if any of the LINK_LIBRARIES are targets in this project, # if so, add them to reqlibname foreach (deplib ${DEPLIBS}) - # If this target exists, get the actual library name (which equates - # to it's .pc filename, example: target dfrph = .pc + # Get the actual library name (which equates to it's .pc filename, + # example: target dfrph = .pc if (TARGET ${deplib}) get_target_property(deplibname ${deplib} PKG_CONFIG_NAME) list(APPEND reqlibname ${deplibname}) - # If the deplib is mraa, add that verbatim (mraa's .pc file is mraa.pc) elseif (${deplib} MATCHES mraa) list(APPEND reqlibname mraa) endif (TARGET ${deplib}) @@ -73,21 +106,100 @@ function (_gen_pkg_config_per_target) # Switch to comma separated Requires: field (per pkg-config docs) string(REPLACE ";" "," reqlibname "${reqlibname}") - # Keep some stats - string(REGEX MATCH "-c$" _isC ${target}) - if (_isC) - MATH(EXPR n_ctargets "${n_ctargets}+1") - else () - MATH(EXPR n_cxxtargets "${n_cxxtargets}+1") - endif() + # Create the .pc file upm_create_install_pkgconfig (${libname}.pc ${LIB_INSTALL_DIR}/pkgconfig) endif (TARGET ${target}) - endforeach (target ${UPM_LIBRARY_TARGETS}) - message(STATUS "\tFound C libraries: ${n_ctargets}") - message(STATUS "\tFound CXX libraries: ${n_cxxtargets}") - message(STATUS "Generating pkg-config files for ${n_targets} libraries... Complete") + endforeach (target ${ARGN}) + message(STATUS "Generating pkg-config files for ${n_targets} ${LABEL} libraries... Complete") endfunction (_gen_pkg_config_per_target) +# This function iterates over all provided target names and +# writes a pom file to each build directory +function (_gen_pom_per_target) + list(LENGTH ARGN n_targets) + message(STATUS "Generating pom files for ${n_targets} CXX libraries...") + # Iterate over the targets an build pom files + foreach (target ${ARGN}) + if (TARGET ${target}) + get_target_property(libname ${target} PKG_CONFIG_NAME) + get_target_property(libdescription ${target} PKG_CONFIG_DESCRIPTION) + get_target_property(reqlibname ${target} PKG_EXT_REQ_LIBS) + get_target_property(BINARY_DIR ${target} BINARY_DIR) + + # Get a list of in-project dependency targets for this target + _get_dependency_targets(${target} DEPLIBS) + + # Default the packaging for java + set (pom_packaging jar) + # Default the groupid for java + set (pom_base_groupId io.mraa) + if (ANDROID) + # Android overrides + set (pom_packaging aar) + set (pom_base_groupId io.mraa.at) + endif (ANDROID) + + # Top-level pom groupId + set (pom_groupId ${pom_base_groupId}.upm) + + # Template for a single dependency + set (pom_dep_template " + + \@pom_dep_groupId\@ + \@deplib\@ + [\@pom_version_minimum\@, \) + compile + ") + + # Iterate over the dependency targets, build an XML vector of dependencies + set (pom_dependencies "") + foreach (deplib ${DEPLIBS}) + unset(_tmp_pom_dep) + # mraa is a special case + if (${deplib} MATCHES mraa) + set (pom_dep_groupId "${pom_base_groupId}") + set (pom_version_minimum ${MRAA_MINIMUM}) + string(CONFIGURE ${pom_dep_template} _tmp_pom_dep @ONLY) + # Only match CXX target dependencies + elseif ("${UPM_TARGETS_CXX}" MATCHES ";${deplib};") + set (deplib upm_${deplib}) + set (pom_dep_groupId "${pom_base_groupId}.upm") + set (pom_version_minimum ${upm_VERSION_STRING}) + string(CONFIGURE ${pom_dep_template} _tmp_pom_dep @ONLY) + endif (${deplib} MATCHES mraa) + + # Add this dependency to the list of pom dependencies + set (pom_dependencies "${pom_dependencies}${_tmp_pom_dep}") + endforeach (deplib ${DEPLIBS}) + + # Separate the dependency elements + STRING(REGEX REPLACE ";" "\\n;" pom_dependencies "${pom_dependencies}") + # Configure the pom file + configure_file (${CMAKE_SOURCE_DIR}/src/pom.xml.in + ${BINARY_DIR}/upm_${target}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.pom) + endif (TARGET ${target}) + endforeach (target ${ARGN}) + message(STATUS "Generating pom files for ${n_targets} CXX libraries... Complete") +endfunction (_gen_pom_per_target) + +# Print out a quick summary of the UPM targets +function (_print_target_summary) + list(LENGTH UPM_TARGETS_C N_C) + list(LENGTH UPM_TARGETS_CXX N_CXX) + list(LENGTH UPM_TARGETS_JAVA N_JAVA) + list(LENGTH UPM_TARGETS_NODEJS N_NODEJS) + list(LENGTH UPM_TARGETS_PYTHON2 N_PYTHON2) + list(LENGTH UPM_TARGETS_PYTHON3 N_PYTHON3) + + message(STATUS "UPM target summary:") + message(STATUS "\tFound C libraries: ${N_C}") + message(STATUS "\tFound CXX libraries: ${N_CXX}") + message(STATUS "\tFound JAVA libraries: ${N_JAVA}") + message(STATUS "\tFound NODEJS libraries: ${N_NODEJS}") + message(STATUS "\tFound PYTHON2 libraries: ${N_PYTHON2}") + message(STATUS "\tFound PYTHON3 libraries: ${N_PYTHON3}") +endfunction (_print_target_summary) + function (_get_target_dependency_interface_include_dirs target varIncludeDirs) set (${varIncludeDirs} "") @@ -117,7 +229,8 @@ macro(_upm_swig_python) # wrapper generation. Get them manually and add them here. _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) - include_directories (${UPM_COMMON_HEADER_DIRS} + include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/.. ${DEPEND_DIRS}) set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON) @@ -139,6 +252,7 @@ macro(_upm_swig_python) swig_add_module (${python_wrapper_name} python pyupm_${libname}.i) # Get target library name (example _pyupm_a110x-python2) set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME}) + add_dependencies(${python_wrapper_target} ${libname}) swig_link_libraries (${python_wrapper_name} ${PYTHON_LIBRARIES} ${libname}) target_include_directories (${python_wrapper_target} @@ -196,6 +310,10 @@ macro(upm_swig_python) set(PYTHON_VERSION_MINOR ${PYTHON2_VERSION_MINOR}) set(PYTHON_PACKAGES_PATH ${PYTHON2_PACKAGES_PATH}) _upm_swig_python() + + # Keep track of all Python2 targets + set(UPM_TARGETS_PYTHON2 ${UPM_TARGETS_PYTHON2} ${python_wrapper_target} + CACHE INTERNAL "List of Python target names") endif (PYTHON2LIBS_FOUND) # Generate python3 module if python3 libs are available @@ -207,6 +325,10 @@ macro(upm_swig_python) set(PYTHON_VERSION_MINOR ${PYTHON3_VERSION_MINOR}) set(PYTHON_PACKAGES_PATH ${PYTHON3_PACKAGES_PATH}) _upm_swig_python() + + # Keep track of all Python3 targets + set(UPM_TARGETS_PYTHON3 ${UPM_TARGETS_PYTHON3} ${python_wrapper_target} + CACHE INTERNAL "List of Python target names") endif (PYTHON3LIBS_FOUND) endif (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};") endmacro(upm_swig_python) @@ -229,14 +351,14 @@ macro(upm_swig_node) # wrapper generation. Get them manually and add them here. _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) - include_directories ( - ${UPM_COMMON_HEADER_DIRS} - ${DEPEND_DIRS} - ) + include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${DEPEND_DIRS}) set_property (SOURCE jsupm_${libname}.i PROPERTY SWIG_FLAGS "-node" "-DV8_VERSION=${V8_VERSION_HEX}") set_source_files_properties (jsupm_${libname}.i PROPERTIES CPLUSPLUS ON) swig_add_module (jsupm_${libname} javascript jsupm_${libname}.i) + add_dependencies(jsupm_${libname} ${libname}) swig_link_libraries (jsupm_${libname} ${NODE_LIBRARIES} ${libname}) target_include_directories ( ${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PUBLIC @@ -277,6 +399,9 @@ macro(upm_swig_node) install (TARGETS jsupm_${libname} DESTINATION ${NODE_MODULE_INSTALL_PATH}) endif (NOT ";${NODESWIG_BLACKLIST};" MATCHES ";${libname};") + + # Keep track of all NODE targets + set(UPM_TARGETS_NODEJS ${UPM_TARGETS_NODEJS} jsupm_${libname} CACHE INTERNAL "List of NodeJs target names") endmacro(upm_swig_node) macro(upm_swig_java) @@ -289,7 +414,8 @@ macro(upm_swig_java) include_directories ( ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} - ${UPM_COMMON_HEADER_DIRS} + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/.. ${DEPEND_DIRS} ) @@ -302,7 +428,8 @@ macro(upm_swig_java) # See issue #518 # TODO: Fix this somehow swig_add_module (javaupm_${libname} java javaupm_${libname}.i ${module_src}) - swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARY} ${JAVA_LIBRARIES} ${libname} interfaces) + swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARY} ${JAVA_LIBRARIES} ${libname}) + add_dependencies(javaupm_${libname} ${libname}) target_include_directories ( ${SWIG_MODULE_javaupm_${libname}_REAL_NAME} PUBLIC "${JAVA_INCLUDE_DIRS}" @@ -347,8 +474,8 @@ macro(upm_swig_java) COMMAND ${JAR} cvf upm_${libname}.jar upm_${libname} ) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/../pom.xml.in - ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.pom) + # Keep track of all JAVA targets + set(UPM_TARGETS_JAVA ${UPM_TARGETS_JAVA} javaupm_${libname} CACHE INTERNAL "List of JAVA target names") endif (NOT ";${JAVASWIG_BLACKLIST};" MATCHES ";${libname};") endmacro(upm_swig_java) @@ -483,11 +610,6 @@ function (UPM_MIXED_MODULE_INIT) set (module_src ${UPM_MIXED_MODULE_INIT_C_SRC}) set (module_hpp ${UPM_MIXED_MODULE_INIT_C_HDR}) - # Append the utilities-c target to each c target - if (NOT ${libname} MATCHES "utilities") - list (APPEND UPM_MIXED_MODULE_INIT_REQUIRES utilities-c) - endif() - # If building FTI, and FTI src exists, add it in if (BUILDFTI AND UPM_MIXED_MODULE_INIT_FTI_SRC) #set (module_src ${UPM_MIXED_MODULE_INIT_C_SRC} ${UPM_MIXED_MODULE_INIT_FTI_SRC}) @@ -498,11 +620,17 @@ function (UPM_MIXED_MODULE_INIT) set (IS_C_LIBRARY TRUE) upm_module_init(${UPM_MIXED_MODULE_INIT_REQUIRES}) - # add upmc-utilities as a dependancy to all C libs (but NOT to the - # utilities lib itself) - if (NOT ${libname} MATCHES "utilities-c") - target_link_libraries (${libname} utilities-c) - endif() + # If a c target has a dependency on utilities-c, then swap the corresponding + # C++ target's dependency on utilities-c to utilities. This solves a niche + # problem for Android Things (C++ which depends on C which depends on + # utilities-c is not getting the utilities-c library). Since only C++ + # packages get swig'ed to Java, the only way to get the utilities-c library + # is to packages with a utilites C++ library and add a dependency. + # TODO: Find a better way to do this. + if ("${UPM_MIXED_MODULE_INIT_REQUIRES}" MATCHES utilities-c) + list (REMOVE_ITEM UPM_MIXED_MODULE_INIT_REQUIRES utilities-c) + list (APPEND UPM_MIXED_MODULE_INIT_REQUIRES utilities) + endif () ## "export" the logical C lib target for the calling module's ## CMakeLists.txt @@ -543,21 +671,24 @@ function(upm_module_init) # If this is a C library, export C library target name to parent's libname set (libname ${libname} PARENT_SCOPE) set (libprefix upmc-) + # Keep track of all C targets + set(UPM_TARGETS_C ${UPM_TARGETS_C} ${libname} CACHE INTERNAL "List of C target names") else () + # Keep track of all CXX targets + set(UPM_TARGETS_CXX ${UPM_TARGETS_CXX} ${libname} CACHE INTERNAL "List of CXX target names") set (libprefix upm-) endif (IS_C_LIBRARY) # Create the target library from src/hdrs add_library (${libname} SHARED ${module_src} ${module_hpp}) - target_include_directories (${libname} PUBLIC - ${UPM_COMMON_HEADER_DIRS} - ${CMAKE_SOURCE_DIR}/src/utilities) - # Specify the current source directory as an INTERFACE include dir. # This allows for transitive header dependencies via target_link_libraries target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + # Also add common header directories to this target + target_include_directories (${libname} PUBLIC ${UPM_COMMON_HEADER_DIRS}) + # Iterate over all arguments passed to upm_module_init. # 1. Add them via target_link_libraries # 2. If mraa, then add a link and include dependency @@ -594,8 +725,7 @@ function(upm_module_init) endif (BUILDSWIGJAVA) endif (NOT IS_C_LIBRARY) - # Add this target to the list of library target names - set(UPM_LIBRARY_TARGETS ${UPM_LIBRARY_TARGETS} ${libname} CACHE INTERNAL "List of ALL target names") + # Add additional properties to this target (used later for .pc file creation) set_target_properties(${libname} PROPERTIES PKG_CONFIG_NAME "${libprefix}${basename}") set_target_properties(${libname} PROPERTIES PKG_CONFIG_DESCRIPTION "${libdescription}") set_target_properties(${libname} PROPERTIES PKG_EXT_REQ_LIBS "${reqlibname}") @@ -647,8 +777,13 @@ elseif (BUILDSWIGPYTHON) file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/pyupm_doxy2swig.i "// Empty doxy2swig stub") endif (BUILDDOC AND BUILDSWIGPYTHON) -# Provide a cached variable to save a list of library target names -set(UPM_LIBRARY_TARGETS "" CACHE INTERNAL "List of ALL target names") +# Provide a cached variable to groups of targets +set(UPM_TARGETS_C "" CACHE INTERNAL "List of C target names") +set(UPM_TARGETS_CXX "" CACHE INTERNAL "List of CXX target names") +set(UPM_TARGETS_JAVA "" CACHE INTERNAL "List of JAVA target names") +set(UPM_TARGETS_NODEJS "" CACHE INTERNAL "List of NodeJs target names") +set(UPM_TARGETS_PYTHON2 "" CACHE INTERNAL "List of Python2 target names") +set(UPM_TARGETS_PYTHON3 "" CACHE INTERNAL "List of Python3 target names") # Add subdirectories from MODULE_LIST if defined # Example -DMODULE_LIST="dfrph;rotaryencoder" @@ -674,5 +809,14 @@ foreach(subdir ${SUBDIRS}) endif() endforeach() +# Print stats for all targets +_print_target_summary() + # Generate a pkg-config file (.pc) per target -_gen_pkg_config_per_target() +_gen_pkg_config_per_target(C ${UPM_TARGETS_C}) +_gen_pkg_config_per_target(CXX ${UPM_TARGETS_CXX}) + +# Generate a pom file per CXX target +if (BUILDSWIGJAVA) + _gen_pom_per_target(${UPM_TARGETS_CXX}) +endif (BUILDSWIGJAVA) diff --git a/src/apds9930/CMakeLists.txt b/src/apds9930/CMakeLists.txt index cc950d04..42cad3d7 100755 --- a/src/apds9930/CMakeLists.txt +++ b/src/apds9930/CMakeLists.txt @@ -1,5 +1,7 @@ -set (libname "apds9930") -set (libdescription "Digital Ambient Light and Proximity Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) +if (MRAA_IIO_FOUND) + set (libname "apds9930") + set (libdescription "Digital Ambient Light and Proximity Sensor") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) +endif (MRAA_IIO_FOUND) diff --git a/src/bacnetmstp/bacnetmstp.cxx b/src/bacnetmstp/bacnetmstp.cxx index f3264329..7807c179 100644 --- a/src/bacnetmstp/bacnetmstp.cxx +++ b/src/bacnetmstp/bacnetmstp.cxx @@ -285,7 +285,7 @@ BACNETMSTP* BACNETMSTP::instance() return m_instance; } -void BACNETMSTP::initMaster(std::string port, int baudRate, +void BACNETMSTP::initMaster(string port, int baudRate, int deviceInstanceID, int macAddr, int maxMaster, int maxInfoFrames) { @@ -305,7 +305,7 @@ void BACNETMSTP::initMaster(std::string port, int baudRate, if ( !(baudRate == 9600 || baudRate == 19200 || baudRate == 38400 || baudRate == 57600 || baudRate == 76800 || baudRate == 115200) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": baudRate must be 9600, 19200, 38400, " + " 57600, 76800, or 115200"); } @@ -314,26 +314,26 @@ void BACNETMSTP::initMaster(std::string port, int baudRate, // maxMaster must be less than or equal to 127 if (maxMaster < 0 || maxMaster > DEFAULT_MAX_MASTER) { - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": maxMaster must be between 0 and " - + std::to_string(DEFAULT_MAX_MASTER)); + + to_string(DEFAULT_MAX_MASTER)); } // As a master ourselves, we must have a MAC address also within the // constraints of maxMaster if (macAddr < 0 || macAddr > DEFAULT_MAX_MASTER) { - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": macAddr must be between 0 and " - + std::to_string(DEFAULT_MAX_MASTER)); + + to_string(DEFAULT_MAX_MASTER)); } // this should be unique on the network if (deviceInstanceID >= BACNET_MAX_INSTANCE) { - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": deviceInstanceID must be less than " - + std::to_string(BACNET_MAX_INSTANCE) + + to_string(BACNET_MAX_INSTANCE) + ", and must be unique on the network"); } @@ -506,7 +506,7 @@ bool BACNETMSTP::dispatchRequest() break; default: syslog(LOG_WARNING, "%s: switch case not defined", - std::string(__FUNCTION__).c_str()); + string(__FUNCTION__).c_str()); } } else if (tsm_invoke_id_free(m_invokeID)) @@ -584,9 +584,9 @@ bool BACNETMSTP::readProperty(uint32_t targetDeviceInstanceID, // some sanity checking... if (objInstance >= BACNET_MAX_INSTANCE) { - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": objInstance must be less than " - + std::to_string(BACNET_MAX_INSTANCE)); + + to_string(BACNET_MAX_INSTANCE)); } // fill in the command structure and dispatch @@ -620,9 +620,9 @@ bool BACNETMSTP::writeProperty(uint32_t targetDeviceInstanceID, // some sanity checking... if (objInstance >= BACNET_MAX_INSTANCE) { - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": objInstance must be less than " - + std::to_string(BACNET_MAX_INSTANCE)); + + to_string(BACNET_MAX_INSTANCE)); } // fill in the command structure and dispatch @@ -681,9 +681,9 @@ float BACNETMSTP::getDataTypeReal(int index) case BACNET_APPLICATION_TAG_SIGNED_INT: return float(getDataTypeSignedInt(index)); default: - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to Real"); } } @@ -694,9 +694,9 @@ bool BACNETMSTP::getDataTypeBoolean(int index) if (getDataType(index) == BACNET_APPLICATION_TAG_BOOLEAN) return ((m_returnedValue.at(index).type.Boolean) ? true : false); else - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to Bool"); } @@ -705,9 +705,9 @@ unsigned int BACNETMSTP::getDataTypeUnsignedInt(int index) if (getDataType(index) == BACNET_APPLICATION_TAG_UNSIGNED_INT) return m_returnedValue.at(index).type.Unsigned_Int; else - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to UnsignedInt"); } @@ -716,9 +716,9 @@ int BACNETMSTP::getDataTypeSignedInt(int index) if (getDataType(index) == BACNET_APPLICATION_TAG_SIGNED_INT) return m_returnedValue.at(index).type.Signed_Int; else - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to SignedInt"); } @@ -744,9 +744,9 @@ double BACNETMSTP::getDataTypeDouble(int index) case BACNET_APPLICATION_TAG_SIGNED_INT: return double(getDataTypeSignedInt(index)); default: - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to Double"); } } @@ -758,35 +758,35 @@ unsigned int BACNETMSTP::getDataTypeEnum(int index) if (getDataType(index) == BACNET_APPLICATION_TAG_ENUMERATED) return m_returnedValue.at(index).type.Enumerated; else - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to Enum"); } -std::string BACNETMSTP::getDataTypeString(int index) +string BACNETMSTP::getDataTypeString(int index) { - string retval; + string retval; // Here, we can try to accomodate all the types switch(getDataType(index)) { case BACNET_APPLICATION_TAG_REAL: - retval = std::to_string(getDataTypeReal(index)); + retval = to_string(getDataTypeReal(index)); break; #if defined(BACAPP_DOUBLE) case BACNET_APPLICATION_TAG_DOUBLE: - retval = std::to_string(getDataTypeDouble(index)); + retval = to_string(getDataTypeDouble(index)); break; #endif // BACAPP_DOUBLE case BACNET_APPLICATION_TAG_UNSIGNED_INT: - retval = std::to_string(getDataTypeUnsignedInt(index)); + retval = to_string(getDataTypeUnsignedInt(index)); break; case BACNET_APPLICATION_TAG_SIGNED_INT: - retval = std::to_string(getDataTypeSignedInt(index)); + retval = to_string(getDataTypeSignedInt(index)); break; case BACNET_APPLICATION_TAG_BOOLEAN: @@ -801,7 +801,7 @@ std::string BACNETMSTP::getDataTypeString(int index) case BACNET_APPLICATION_TAG_OCTET_STRING: { - string tmpstr((char *)octetstring_value(&m_returnedValue.at(index).type.Octet_String), + string tmpstr((char *)octetstring_value(&m_returnedValue.at(index).type.Octet_String), octetstring_length(&m_returnedValue.at(index).type.Octet_String)); retval = string2HexString(tmpstr); @@ -829,9 +829,9 @@ std::string BACNETMSTP::getDataTypeString(int index) break; default: - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": data type (" - + std::to_string(int(getDataType(index))) + + to_string(int(getDataType(index))) + ") is not convertible to String"); break; } @@ -891,9 +891,9 @@ BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataString(string value) { if (value.size() > (MAX_CHARACTER_STRING_BYTES - 1)) { - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": value must be less than or equal to " - + std::to_string(MAX_CHARACTER_STRING_BYTES - 1) + + to_string(MAX_CHARACTER_STRING_BYTES - 1) + " characters long"); } diff --git a/src/bacnetmstp/bacnetutil.cxx b/src/bacnetmstp/bacnetutil.cxx index 98dd6de7..beec7023 100644 --- a/src/bacnetmstp/bacnetutil.cxx +++ b/src/bacnetmstp/bacnetutil.cxx @@ -70,7 +70,7 @@ BACNETUTIL::~BACNETUTIL() { } -void BACNETUTIL::initMaster(std::string port, int baudRate, +void BACNETUTIL::initMaster(string port, int baudRate, int deviceInstanceID, int macAddr, int maxMaster, int maxInfoFrames) { @@ -109,7 +109,7 @@ float BACNETUTIL::getAnalogValue(uint32_t objInstance) cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + getAllErrorString()); } @@ -121,7 +121,7 @@ float BACNETUTIL::getAnalogValue(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": Reliability check failed" << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": Reliability check failed"); } } @@ -134,7 +134,7 @@ float BACNETUTIL::getAnalogValue(uint32_t objInstance) cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -158,7 +158,7 @@ void BACNETUTIL::setAnalogValue(uint32_t objInstance, if (m_debugging) cerr << __FUNCTION__ << ": " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -201,7 +201,7 @@ float BACNETUTIL::getAnalogInput(uint32_t objInstance) cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + getAllErrorString()); } @@ -213,7 +213,7 @@ float BACNETUTIL::getAnalogInput(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": Reliability check failed" << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": Reliability check failed"); } } @@ -225,7 +225,7 @@ float BACNETUTIL::getAnalogInput(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -248,7 +248,7 @@ bool BACNETUTIL::getBinaryInput(uint32_t objInstance) cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + getAllErrorString()); } @@ -260,7 +260,7 @@ bool BACNETUTIL::getBinaryInput(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": Reliability check failed" << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": Reliability check failed"); } } @@ -272,7 +272,7 @@ bool BACNETUTIL::getBinaryInput(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -298,7 +298,7 @@ bool BACNETUTIL::getBinaryValue(uint32_t objInstance) cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + getAllErrorString()); } @@ -310,7 +310,7 @@ bool BACNETUTIL::getBinaryValue(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": Reliability check failed" << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": Reliability check failed"); } } @@ -322,7 +322,7 @@ bool BACNETUTIL::getBinaryValue(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -351,7 +351,7 @@ void BACNETUTIL::setBinaryValue(uint32_t objInstance, if (m_debugging) cerr << __FUNCTION__ << ": " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -398,7 +398,7 @@ unsigned int BACNETUTIL::getMultiStateValue(uint32_t objInstance) cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + getAllErrorString()); } @@ -410,7 +410,7 @@ unsigned int BACNETUTIL::getMultiStateValue(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": Reliability check failed" << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": Reliability check failed"); } } @@ -423,7 +423,7 @@ unsigned int BACNETUTIL::getMultiStateValue(uint32_t objInstance) if (m_debugging) cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -451,7 +451,7 @@ void BACNETUTIL::updateMultiStateValueInfo(uint32_t objInstance) << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -525,10 +525,10 @@ string BACNETUTIL::lookupMultiStateValueText(uint32_t objInstance, // verify that value is valid for this object if (value == 0 || value > m_msvInfo[objInstance].numStates) - throw std::out_of_range(std::string(__FUNCTION__) + throw out_of_range(string(__FUNCTION__) + ": value supplied is invalid. Maximum " + "allowed values are 1 to " - + std::to_string(m_msvInfo[objInstance].numStates) + + to_string(m_msvInfo[objInstance].numStates) + " for this object"); @@ -549,7 +549,7 @@ string BACNETUTIL::lookupMultiStateValueText(uint32_t objInstance, } // no stateList text available, so just return value as a string - return std::to_string(value); + return to_string(value); } unsigned int BACNETUTIL::getMultiStateValueMaxStates(uint32_t objInstance) @@ -576,10 +576,10 @@ void BACNETUTIL::setMultiStateValue(uint32_t objInstance, // Check value against the valid limits if (value == 0 || value > m_msvInfo[objInstance].numStates) - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": value supplied is invalid. Maximum " + "allowed values are 1 to " - + std::to_string(m_msvInfo[objInstance].numStates) + + to_string(m_msvInfo[objInstance].numStates) + " for this object"); // Write the value @@ -596,7 +596,7 @@ void BACNETUTIL::setMultiStateValue(uint32_t objInstance, if (m_debugging) cerr << __FUNCTION__ << ": " << getAllErrorString() << endl; - throw std::runtime_error(std::string(__FUNCTION__) + throw runtime_error(string(__FUNCTION__) + ": " + getAllErrorString()); } @@ -772,7 +772,7 @@ uint8_t BACNETUTIL::getRejectReason() return m_instance->getRejectReason(); } -std::string BACNETUTIL::getRejectString() +string BACNETUTIL::getRejectString() { return m_instance->getRejectString(); } @@ -782,7 +782,7 @@ uint8_t BACNETUTIL::getAbortReason() return m_instance->getAbortReason(); } -std::string BACNETUTIL::getAbortString() +string BACNETUTIL::getAbortString() { return m_instance->getAbortString(); } @@ -797,12 +797,12 @@ BACNET_ERROR_CODE BACNETUTIL::getErrorCode() return m_instance->getErrorCode(); } -std::string BACNETUTIL::getUPMErrorString() +string BACNETUTIL::getUPMErrorString() { return m_instance->getUPMErrorString(); } -std::string BACNETUTIL::getErrorString() +string BACNETUTIL::getErrorString() { return m_instance->getErrorString(); }; @@ -904,7 +904,7 @@ bool BACNETUTIL::setDeviceName(string name) { if (name.size() < 1) { - throw std::invalid_argument(std::string(__FUNCTION__) + throw invalid_argument(string(__FUNCTION__) + ": name must have at least one character"); } diff --git a/src/bh1750/CMakeLists.txt b/src/bh1750/CMakeLists.txt index d3717dd6..0ffc6ea3 100644 --- a/src/bh1750/CMakeLists.txt +++ b/src/bh1750/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bh1750 CPP_SRC bh1750.cxx FTI_SRC bh1750_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/bma250e/CMakeLists.txt b/src/bma250e/CMakeLists.txt index c4ed3bae..8c72bb78 100644 --- a/src/bma250e/CMakeLists.txt +++ b/src/bma250e/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bma250e CPP_SRC bma250e.cxx FTI_SRC bma250e_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/bmg160/CMakeLists.txt b/src/bmg160/CMakeLists.txt index 0bdefc22..eee87db3 100644 --- a/src/bmg160/CMakeLists.txt +++ b/src/bmg160/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bmg160 CPP_SRC bmg160.cxx FTI_SRC bmg160_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/bmi160/CMakeLists.txt b/src/bmi160/CMakeLists.txt index 5897de2f..283acfb1 100644 --- a/src/bmi160/CMakeLists.txt +++ b/src/bmi160/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bmi160 CPP_SRC bmi160.cxx # FTI_SRC bmi160_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/bmm150/CMakeLists.txt b/src/bmm150/CMakeLists.txt index 46f9d809..e2ca296b 100644 --- a/src/bmm150/CMakeLists.txt +++ b/src/bmm150/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bmm150 CPP_SRC bmm150.cxx FTI_SRC bmm150_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/bmp280/CMakeLists.txt b/src/bmp280/CMakeLists.txt index 53d3b18f..4864a80e 100644 --- a/src/bmp280/CMakeLists.txt +++ b/src/bmp280/CMakeLists.txt @@ -5,5 +5,5 @@ upm_mixed_module_init (NAME bmp280 CPP_HDR bmp280.hpp bme280.hpp CPP_SRC bmp280.cxx bme280.cxx CPP_WRAPS_C - REQUIRES mraa interfaces) + REQUIRES mraa interfaces utilities-c) target_link_libraries(${libnamec} m) diff --git a/src/bmp280/bme280.cxx b/src/bmp280/bme280.cxx index 17c7a248..7936cc7d 100644 --- a/src/bmp280/bme280.cxx +++ b/src/bmp280/bme280.cxx @@ -54,5 +54,3 @@ void BME280::setOversampleRateHumidity(BME280_OSRS_H_T rate) { bmp280_set_oversample_rate_humidity(m_bmp280, rate); } - - diff --git a/src/bmpx8x/CMakeLists.txt b/src/bmpx8x/CMakeLists.txt index 8b3ce578..ea363518 100644 --- a/src/bmpx8x/CMakeLists.txt +++ b/src/bmpx8x/CMakeLists.txt @@ -6,5 +6,5 @@ upm_mixed_module_init (NAME bmpx8x CPP_SRC bmpx8x.cxx FTI_SRC bmpx8x_fti.c CPP_WRAPS_C - REQUIRES mraa interfaces) + REQUIRES mraa interfaces utilities-c) target_link_libraries(${libnamec} m) diff --git a/src/bno055/CMakeLists.txt b/src/bno055/CMakeLists.txt index 9a8985f5..5dc45e67 100644 --- a/src/bno055/CMakeLists.txt +++ b/src/bno055/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME bno055 CPP_HDR bno055.hpp CPP_SRC bno055.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/buzzer/CMakeLists.txt b/src/buzzer/CMakeLists.txt index 05231f81..d4917f7e 100644 --- a/src/buzzer/CMakeLists.txt +++ b/src/buzzer/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME buzzer CPP_SRC buzzer.cxx # FTI_SRC buzzer_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/cjq4435/CMakeLists.txt b/src/cjq4435/CMakeLists.txt index b61a9b8d..a225477d 100644 --- a/src/cjq4435/CMakeLists.txt +++ b/src/cjq4435/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME cjq4435 CPP_HDR cjq4435.hpp CPP_SRC cjq4435.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/curieimu/CMakeLists.txt b/src/curieimu/CMakeLists.txt index 92248faf..8f208c31 100644 --- a/src/curieimu/CMakeLists.txt +++ b/src/curieimu/CMakeLists.txt @@ -1,8 +1,4 @@ -include (CheckFunctionExists) -include (CheckLibraryExists) -include (CheckIncludeFiles) -check_library_exists (${MRAA_LIBRARIES} mraa_firmata_init "" HAVE_FIRMATA) -if (HAVE_FIRMATA) +if (MRAA_FIRMATA_FOUND) set (libname "curieimu") set (libdescription "Curie IMU Sensor using Firmata") set (module_src ${libname}.cpp) diff --git a/src/dfrec/CMakeLists.txt b/src/dfrec/CMakeLists.txt index b106ae40..54d55c27 100644 --- a/src/dfrec/CMakeLists.txt +++ b/src/dfrec/CMakeLists.txt @@ -1,13 +1,14 @@ -upm_mixed_module_init (NAME dfrec - DESCRIPTION "Analog Electrical Conductivity (EC) Sensor" - C_HDR dfrec.h - C_SRC dfrec.c - CPP_HDR dfrec.hpp - CPP_SRC dfrec.cxx - FTI_SRC dfrec_fti.c - CPP_WRAPS_C - REQUIRES ds18b20 mraa) - -# make sure the C library has the appropriate dependency on the UPM -# DS18B20 C library -target_link_libraries(${libnamec} ds18b20-c) +if (MRAA_OW_FOUND) + upm_mixed_module_init (NAME dfrec + DESCRIPTION "Analog Electrical Conductivity (EC) Sensor" + C_HDR dfrec.h + C_SRC dfrec.c + CPP_HDR dfrec.hpp + CPP_SRC dfrec.cxx + FTI_SRC dfrec_fti.c + CPP_WRAPS_C + REQUIRES ds18b20 mraa utilities-c) + # make sure the C library has the appropriate dependency on the UPM + # DS18B20 C library + target_link_libraries(${libnamec} ds18b20-c) +endif (MRAA_OW_FOUND) diff --git a/src/dfrec/dfrec.cxx b/src/dfrec/dfrec.cxx index fd729c2a..1c899620 100644 --- a/src/dfrec/dfrec.cxx +++ b/src/dfrec/dfrec.cxx @@ -23,6 +23,7 @@ */ #include +#include #include #include "dfrec.hpp" diff --git a/src/dfrorp/CMakeLists.txt b/src/dfrorp/CMakeLists.txt index d24071bf..b365a519 100644 --- a/src/dfrorp/CMakeLists.txt +++ b/src/dfrorp/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME dfrorp CPP_SRC dfrorp.cxx FTI_SRC dfrorp_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/dfrorp/dfrorp.cxx b/src/dfrorp/dfrorp.cxx index c41b76a0..1eeaf381 100644 --- a/src/dfrorp/dfrorp.cxx +++ b/src/dfrorp/dfrorp.cxx @@ -51,7 +51,7 @@ void DFRORP::update() { throw std::runtime_error(string(__FUNCTION__) + ": dfrorp_update() failed with UPM error " - + std::to_string(int(rv)) ); + + to_string(int(rv)) ); } } diff --git a/src/ds1808lc/mraa-utils.cxx b/src/ds1808lc/mraa-utils.cxx index b0e9d92c..369dce10 100644 --- a/src/ds1808lc/mraa-utils.cxx +++ b/src/ds1808lc/mraa-utils.cxx @@ -22,10 +22,13 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include +#include + #include "mraa-utils.hpp" #include "mraa/gpio.hpp" - #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg)) +#define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg)) void MraaUtils::setGpio(int pin, int level) { diff --git a/src/ds18b20/CMakeLists.txt b/src/ds18b20/CMakeLists.txt index 570189a8..c3948cb5 100644 --- a/src/ds18b20/CMakeLists.txt +++ b/src/ds18b20/CMakeLists.txt @@ -1,9 +1,11 @@ -upm_mixed_module_init (NAME ds18b20 - DESCRIPTION "Programmable Resolution 1-Wire Digital Thermometer" - C_HDR ds18b20.h ds18b20_defs.h - C_SRC ds18b20.c - CPP_HDR ds18b20.hpp - CPP_SRC ds18b20.cxx - FTI_SRC ds18b20_fti.c - CPP_WRAPS_C - REQUIRES mraa) +if (MRAA_OW_FOUND) + upm_mixed_module_init (NAME ds18b20 + DESCRIPTION "Programmable Resolution 1-Wire Digital Thermometer" + C_HDR ds18b20.h ds18b20_defs.h + C_SRC ds18b20.c + CPP_HDR ds18b20.hpp + CPP_SRC ds18b20.cxx + FTI_SRC ds18b20_fti.c + CPP_WRAPS_C + REQUIRES mraa utilities-c) +endif (MRAA_OW_FOUND) diff --git a/src/ds18b20/ds18b20_fti.c b/src/ds18b20/ds18b20_fti.c index f7d89611..53498086 100644 --- a/src/ds18b20/ds18b20_fti.c +++ b/src/ds18b20/ds18b20_fti.c @@ -28,7 +28,7 @@ #include #include "upm_fti.h" -#include "upm_sensor.h" +#include "fti/upm_sensor.h" /** * This file implements the Function Table Interface (FTI) for this sensor diff --git a/src/ds2413/CMakeLists.txt b/src/ds2413/CMakeLists.txt index 812f584b..c5aded6c 100644 --- a/src/ds2413/CMakeLists.txt +++ b/src/ds2413/CMakeLists.txt @@ -1,5 +1,7 @@ -set (libname "ds2413") -set (libdescription "1-Wire Dual Channel Addressable Switch") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) +if (MRAA_OW_FOUND) + set (libname "ds2413") + set (libdescription "1-Wire Dual Channel Addressable Switch") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) +endif (MRAA_OW_FOUND) diff --git a/src/ecezo/CMakeLists.txt b/src/ecezo/CMakeLists.txt index 24222ace..a23f899b 100644 --- a/src/ecezo/CMakeLists.txt +++ b/src/ecezo/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME ecezo CPP_SRC ecezo.cxx FTI_SRC ecezo_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/enc03r/CMakeLists.txt b/src/enc03r/CMakeLists.txt index 8fc2f412..c7ed321c 100644 --- a/src/enc03r/CMakeLists.txt +++ b/src/enc03r/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME enc03r CPP_SRC enc03r.cxx FTI_SRC enc03r_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/guvas12d/CMakeLists.txt b/src/guvas12d/CMakeLists.txt index 3b3501a2..208b3678 100644 --- a/src/guvas12d/CMakeLists.txt +++ b/src/guvas12d/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME guvas12d CPP_SRC guvas12d.cxx FTI_SRC guvas12d_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/hka5/CMakeLists.txt b/src/hka5/CMakeLists.txt index 2d46ef2b..acb4f1aa 100644 --- a/src/hka5/CMakeLists.txt +++ b/src/hka5/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME hka5 CPP_SRC hka5.cxx FTI_SRC hka5_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/hlg150h/mraa-utils.cxx b/src/hlg150h/mraa-utils.cxx index b59c7188..2176b2a0 100644 --- a/src/hlg150h/mraa-utils.cxx +++ b/src/hlg150h/mraa-utils.cxx @@ -22,10 +22,13 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include +#include + #include "mraa-utils.hpp" #include "mraa/gpio.hpp" - #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg)) +#define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg)) void MraaUtils::setGpio(int pin, int level) { diff --git a/src/htu21d/htu21d.cpp b/src/htu21d/htu21d.cpp index 607e8f4e..f1fd15e8 100644 --- a/src/htu21d/htu21d.cpp +++ b/src/htu21d/htu21d.cpp @@ -154,12 +154,12 @@ HTU21D::getDewPoint(int bSampleData) sampleData(); } - float fA = 8.1332; - float fB = 1762.39; - float fC = 235.66; - float fT = getTemperature(false); - float fRH = getHumidity(false); - float fPP = exp10(fA - (fB / (fT + fC))); + float fA = 8.1332; + float fB = 1762.39; + float fC = 235.66; + float fT = getTemperature(false); + float fRH = getHumidity(false); + float fPP = powf(10, fA - (fB / (fT + fC))); float fDP = -(fB / (log10(fRH * fPP / 100) - fA) + fC); return (fDP); diff --git a/src/htu21d/javaupm_htu21d.i b/src/htu21d/javaupm_htu21d.i index a5f8de50..14a87158 100644 --- a/src/htu21d/javaupm_htu21d.i +++ b/src/htu21d/javaupm_htu21d.i @@ -5,14 +5,10 @@ %apply float *OUTPUT {float *fHum}; %apply float *OUTPUT {float *fHumTemp}; %apply float *OUTPUT {float *fDewPt}; -%inline %{ - extern int getHumidityData(float* fHum, float* fHumTemp, float* fDewPt); -%} %{ #include "htu21d.hpp" %} - %include "htu21d.hpp" %pragma(java) jniclasscode=%{ diff --git a/src/ims/CMakeLists.txt b/src/ims/CMakeLists.txt index 7f2c490e..816b478e 100644 --- a/src/ims/CMakeLists.txt +++ b/src/ims/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME ims CPP_SRC ims.cxx FTI_SRC ims_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/ims/ims.cxx b/src/ims/ims.cxx index 1831f88f..58c1f869 100644 --- a/src/ims/ims.cxx +++ b/src/ims/ims.cxx @@ -23,6 +23,7 @@ */ #include +#include #include "ims.hpp" diff --git a/src/jhd1313m1/CMakeLists.txt b/src/jhd1313m1/CMakeLists.txt index 374322a3..593c12fe 100644 --- a/src/jhd1313m1/CMakeLists.txt +++ b/src/jhd1313m1/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME jhd1313m1 CPP_HDR jhd1313m1.hpp CPP_SRC jhd1313m1.cxx CPP_WRAPS_C - REQUIRES mraa lcm1602) + REQUIRES mraa lcm1602 utilities-c) diff --git a/src/kxcjk1013/CMakeLists.txt b/src/kxcjk1013/CMakeLists.txt index 90a12fc2..30f0b281 100644 --- a/src/kxcjk1013/CMakeLists.txt +++ b/src/kxcjk1013/CMakeLists.txt @@ -1,5 +1,7 @@ -set (libname "kxcjk1013") -set (libdescription "Tri-axis Digital Accelerometer") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) +if (MRAA_IIO_FOUND) + set (libname "kxcjk1013") + set (libdescription "Tri-axis Digital Accelerometer") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) +endif (MRAA_IIO_FOUND) diff --git a/src/l3gd20/CMakeLists.txt b/src/l3gd20/CMakeLists.txt index fbfa0db0..a91a1f14 100644 --- a/src/l3gd20/CMakeLists.txt +++ b/src/l3gd20/CMakeLists.txt @@ -1,5 +1,7 @@ -set (libname "l3gd20") -set (libdescription "Tri-axis Digital Gyroscope") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) +if (MRAA_IIO_FOUND) + set (libname "l3gd20") + set (libdescription "Tri-axis Digital Gyroscope") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) +endif (MRAA_IIO_FOUND) diff --git a/src/l3gd20/l3gd20.cxx b/src/l3gd20/l3gd20.cxx index 7c3c36d7..48268319 100755 --- a/src/l3gd20/l3gd20.cxx +++ b/src/l3gd20/l3gd20.cxx @@ -138,11 +138,11 @@ L3GD20::L3GD20(int bus, int addr) { throw std::runtime_error(std::string(__FUNCTION__) + ": Invalid Chip ID: expected " - + std::to_string(L3GD20_DEFAULT_CHIP_ID) + + to_string(L3GD20_DEFAULT_CHIP_ID) + " or " - + std::to_string(L3GD20H_DEFAULT_CHIP_ID) + + to_string(L3GD20H_DEFAULT_CHIP_ID) + ", got " - + std::to_string(int(cid))); + + to_string(int(cid))); return; } @@ -282,7 +282,7 @@ void L3GD20::update() { throw std::runtime_error(std::string(__FUNCTION__) + ": readRegs() failed to read " - + std::to_string(bufLen) + + to_string(bufLen) + " bytes"); } diff --git a/src/lcm1602/CMakeLists.txt b/src/lcm1602/CMakeLists.txt index 8dad3da0..8bb3cba6 100644 --- a/src/lcm1602/CMakeLists.txt +++ b/src/lcm1602/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME lcm1602 CPP_HDR lcm1602.hpp CPP_SRC lcm1602.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/lm35/lm35_fti.c b/src/lm35/lm35_fti.c index c4163891..a0b8305e 100644 --- a/src/lm35/lm35_fti.c +++ b/src/lm35/lm35_fti.c @@ -28,7 +28,7 @@ #include #include "upm_fti.h" -#include "upm_sensor.h" +#include "fti/upm_sensor.h" /** * This file implements the Function Table Interface (FTI) for this sensor diff --git a/src/lp8860/mraa-utils.cxx b/src/lp8860/mraa-utils.cxx index b0e9d92c..4d235106 100644 --- a/src/lp8860/mraa-utils.cxx +++ b/src/lp8860/mraa-utils.cxx @@ -22,6 +22,8 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #include "mraa-utils.hpp" #include "mraa/gpio.hpp" diff --git a/src/lsm303agr/CMakeLists.txt b/src/lsm303agr/CMakeLists.txt index 8f8fdbf9..240e3d32 100644 --- a/src/lsm303agr/CMakeLists.txt +++ b/src/lsm303agr/CMakeLists.txt @@ -1,9 +1,9 @@ upm_mixed_module_init (NAME lsm303agr - DESCRIPTION "3-Axis eCompass module" + DESCRIPTION "3-Axis eCompass Module" C_HDR lsm303agr.h lsm303agr_defs.h C_SRC lsm303agr.c CPP_HDR lsm303agr.hpp CPP_SRC lsm303agr.cxx FTI_SRC lsm303agr_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/lsm303d/CMakeLists.txt b/src/lsm303d/CMakeLists.txt index fd3be399..f4347918 100644 --- a/src/lsm303d/CMakeLists.txt +++ b/src/lsm303d/CMakeLists.txt @@ -1,8 +1,8 @@ upm_mixed_module_init (NAME lsm303d - DESCRIPTION "3-Axis eCompass module" + DESCRIPTION "3-Axis eCompass Module" C_HDR lsm303d.h lsm303d_defs.h C_SRC lsm303d.c CPP_HDR lsm303d.hpp CPP_SRC lsm303d.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/m24lr64e/CMakeLists.txt b/src/m24lr64e/CMakeLists.txt index f7d4ec83..65a4442f 100644 --- a/src/m24lr64e/CMakeLists.txt +++ b/src/m24lr64e/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME m24lr64e CPP_SRC m24lr64e.cxx FTI_SRC m24lr64e_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/max30100/CMakeLists.txt b/src/max30100/CMakeLists.txt index 31ff0c50..f2e11c60 100644 --- a/src/max30100/CMakeLists.txt +++ b/src/max30100/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME max30100 CPP_SRC max30100.cxx FTI_SRC max30100_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/max30100/javaupm_max30100.i b/src/max30100/javaupm_max30100.i index c370b689..362c3f4e 100644 --- a/src/max30100/javaupm_max30100.i +++ b/src/max30100/javaupm_max30100.i @@ -1,11 +1,19 @@ -%module(directors="1", threads="1") javaupm_max30100 +#ifdef ANDROID + %module javaupm_max30100 +#else + %module(directors="1", threads="1") javaupm_max30100 +#endif + %include "../upm.i" %{ #include "max30100.hpp" %} -%feature("director") upm::Callback; +#ifndef ANDROID + %feature("director") upm::Callback; +#endif + %include "max30100_regs.h" %include "max30100.hpp" diff --git a/src/max30100/max30100.cxx b/src/max30100/max30100.cxx index c0507d0a..01f64a3f 100644 --- a/src/max30100/max30100.cxx +++ b/src/max30100/max30100.cxx @@ -23,6 +23,8 @@ */ #include +#include + #include "max30100.hpp" using namespace upm; diff --git a/src/mb704x/CMakeLists.txt b/src/mb704x/CMakeLists.txt index 88fd7109..33892a77 100644 --- a/src/mb704x/CMakeLists.txt +++ b/src/mb704x/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME mb704x CPP_SRC mb704x.cxx FTI_SRC mb704x_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/mcp2515/CMakeLists.txt b/src/mcp2515/CMakeLists.txt index 4bd672c5..5feb1059 100644 --- a/src/mcp2515/CMakeLists.txt +++ b/src/mcp2515/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME mcp2515 CPP_HDR mcp2515.hpp CPP_SRC mcp2515.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/md/CMakeLists.txt b/src/md/CMakeLists.txt index 8776d1c6..79cb7f88 100644 --- a/src/md/CMakeLists.txt +++ b/src/md/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME md CPP_HDR md.hpp CPP_SRC md.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/mma7361/CMakeLists.txt b/src/mma7361/CMakeLists.txt index a56cb728..1fc49c90 100644 --- a/src/mma7361/CMakeLists.txt +++ b/src/mma7361/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME mma7361 CPP_SRC mma7361.cxx FTI_SRC mma7361_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/mma7361/mma7361.cxx b/src/mma7361/mma7361.cxx index ebb351c5..f80d5e82 100644 --- a/src/mma7361/mma7361.cxx +++ b/src/mma7361/mma7361.cxx @@ -24,6 +24,7 @@ #include #include +#include #include "mma7361.hpp" @@ -66,7 +67,7 @@ bool MMA7361::isInFreefall() { throw std::runtime_error(string(__FUNCTION__) + ": mma7361_freefall() failed with UPM error " - + std::to_string(int(rv)) ); + + to_string(int(rv)) ); } return freefall; @@ -80,7 +81,7 @@ void MMA7361::enableSelftest(bool enable) { throw std::runtime_error(string(__FUNCTION__) + ": mma7361_selftest() failed with UPM error " - + std::to_string(int(rv)) ); + + to_string(int(rv)) ); } } @@ -92,7 +93,7 @@ void MMA7361::update() { throw std::runtime_error(string(__FUNCTION__) + ": mma7361_update() failed with UPM error " - + std::to_string(int(rv)) ); + + to_string(int(rv)) ); } } diff --git a/src/mmc35240/CMakeLists.txt b/src/mmc35240/CMakeLists.txt index 2464a520..838ca625 100644 --- a/src/mmc35240/CMakeLists.txt +++ b/src/mmc35240/CMakeLists.txt @@ -1,5 +1,7 @@ -set (libname "mmc35240") -set (libdescription "mmc35240 sensor module") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) +if (MRAA_IIO_FOUND) + set (libname "mmc35240") + set (libdescription "mmc35240 sensor module") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) +endif (MRAA_IIO_FOUND) diff --git a/src/mpu9150/mpu60x0.hpp b/src/mpu9150/mpu60x0.hpp index feac7656..2c0e840c 100644 --- a/src/mpu9150/mpu60x0.hpp +++ b/src/mpu9150/mpu60x0.hpp @@ -801,23 +801,6 @@ namespace upm { */ void getGyroscope(float *x, float *y, float *z); -#if defined(SWIGJAVA) || defined(JAVACALLBACK) - /** - * get the accelerometer values - * - * @return Array containing X, Y, Z accelerometer values - */ - float *getAccelerometer(); - - /** - * get the gyroscope values - * - * @return Array containing X, Y, Z gyroscope values - */ - float *getGyroscope(); -#endif - - /** * get the temperature value * diff --git a/src/ms5803/CMakeLists.txt b/src/ms5803/CMakeLists.txt index d4d0921c..e7ba6c40 100644 --- a/src/ms5803/CMakeLists.txt +++ b/src/ms5803/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME ms5803 CPP_SRC ms5803.cxx FTI_SRC ms5803_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/my9221/CMakeLists.txt b/src/my9221/CMakeLists.txt index 5ab50fdc..17daab70 100644 --- a/src/my9221/CMakeLists.txt +++ b/src/my9221/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME my9221 CPP_HDR my9221.hpp groveledbar.hpp grovecircularled.hpp CPP_SRC my9221.cxx groveledbar.cxx grovecircularled.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/nmea_gps/CMakeLists.txt b/src/nmea_gps/CMakeLists.txt index 8ce6ffc8..82c15c58 100644 --- a/src/nmea_gps/CMakeLists.txt +++ b/src/nmea_gps/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME nmea_gps CPP_SRC nmea_gps.cxx FTI_SRC nmea_gps_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/nrf24l01/javaupm_nrf24l01.i b/src/nrf24l01/javaupm_nrf24l01.i index d3e32b93..92543d5c 100644 --- a/src/nrf24l01/javaupm_nrf24l01.i +++ b/src/nrf24l01/javaupm_nrf24l01.i @@ -1,8 +1,13 @@ -%module(directors="1") javaupm_nrf24l01 %include "../upm.i" -%feature("director") Callback; -SWIG_DIRECTOR_OWNED(Callback) +#ifdef ANDROID + %module javaupm_nrf24l01 +#else + %module(directors="1") javaupm_nrf24l01 + %feature("director") Callback; + SWIG_DIRECTOR_OWNED(Callback) +#endif + %include "arrays_java.i"; %apply signed char[] {uint8_t *}; @@ -23,4 +28,4 @@ SWIG_DIRECTOR_OWNED(Callback) System.exit(1); } } -%} \ No newline at end of file +%} diff --git a/src/nrf8001/acilib.cpp b/src/nrf8001/acilib.cpp index a1d2ce3d..6ded0589 100644 --- a/src/nrf8001/acilib.cpp +++ b/src/nrf8001/acilib.cpp @@ -28,6 +28,7 @@ */ #include +#include #include #include "hal_platform.h" diff --git a/src/nunchuck/CMakeLists.txt b/src/nunchuck/CMakeLists.txt index e47cbdaf..9c86fe59 100644 --- a/src/nunchuck/CMakeLists.txt +++ b/src/nunchuck/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME nunchuck CPP_SRC nunchuck.cxx FTI_SRC nunchuck_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/otp538u/CMakeLists.txt b/src/otp538u/CMakeLists.txt index 3fcd8228..2a01bd67 100644 --- a/src/otp538u/CMakeLists.txt +++ b/src/otp538u/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME otp538u CPP_SRC otp538u.cxx FTI_SRC otp538u_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/otp538u/otp538u_fti.c b/src/otp538u/otp538u_fti.c index e79a773e..27373ffc 100644 --- a/src/otp538u/otp538u_fti.c +++ b/src/otp538u/otp538u_fti.c @@ -26,7 +26,7 @@ #include "otp538u.h" #include "upm_fti.h" -#include "upm_sensor.h" +#include "fti/upm_sensor.h" /** * This file implements the Function Table Interface (FTI) for this sensor diff --git a/src/pom.xml.in b/src/pom.xml.in index 6e2bfbd8..37d07d33 100644 --- a/src/pom.xml.in +++ b/src/pom.xml.in @@ -1,25 +1,19 @@ - + 4.0.0 - - io.mraa.upm - upm_@libname@ + @pom_groupId@ + upm_@target@ @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ - jar - - @libname@ - High level repository for sensors that use mraa + @pom_packaging@ + @target@ + @libdescription@ http://upm.mraa.io - MIT License https://github.com/intel-iot-devkit/upm/blob/master/LICENSE - Upm contributors https://github.com/intel-iot-devkit/upm/graphs/contributors @@ -28,20 +22,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma https://github.com/intel-iot-devkit - scm:git:git://github.com/intel-iot-devkit/upm.git scm:git:ssh://github.com:intel-iot-devkit/upm.git https://github.com/intel-iot-devkit/upm/tree/master - - - - io.mraa - mraa - [@MRAA_MINIMUM@, ) - compile - + @pom_dependencies@ - diff --git a/src/ppd42ns/CMakeLists.txt b/src/ppd42ns/CMakeLists.txt index 9a9363da..fdcbced3 100644 --- a/src/ppd42ns/CMakeLists.txt +++ b/src/ppd42ns/CMakeLists.txt @@ -5,5 +5,5 @@ upm_mixed_module_init (NAME ppd42ns CPP_HDR ppd42ns.hpp CPP_SRC ppd42ns.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) target_link_libraries(${libnamec} m) diff --git a/src/pulsensor/javaupm_pulsensor.i b/src/pulsensor/javaupm_pulsensor.i index 5f2669a6..e69289f3 100644 --- a/src/pulsensor/javaupm_pulsensor.i +++ b/src/pulsensor/javaupm_pulsensor.i @@ -1,9 +1,16 @@ -%module(directors="1") javaupm_pulsensor +#ifdef ANDROID + %module javaupm_pulsensor +#else + %module(directors="1") javaupm_pulsensor +#endif + %include "../upm.i" %include "arrays_java.i" -%feature("director") Callback; -SWIG_DIRECTOR_OWNED(Callback) +#ifndef ANDROID + %feature("director") Callback; + SWIG_DIRECTOR_OWNED(Callback) +#endif %ignore sample_thread; %ignore pin_ctx; @@ -26,4 +33,4 @@ SWIG_DIRECTOR_OWNED(Callback) System.exit(1); } } -%} \ No newline at end of file +%} diff --git a/src/rf22/javaupm_rf22.i b/src/rf22/javaupm_rf22.i index 73efb180..f5abf195 100644 --- a/src/rf22/javaupm_rf22.i +++ b/src/rf22/javaupm_rf22.i @@ -1,4 +1,9 @@ -%module(directors="1") javaupm_rf22 +#ifdef ANDROID + %module javaupm_rf22 +#else + %module(directors="1") javaupm_rf22 +#endif + %include "../upm.i" %include "arrays_java.i" %include "typemaps.i" @@ -21,4 +26,4 @@ System.exit(1); } } -%} \ No newline at end of file +%} diff --git a/src/rotaryencoder/rotaryencoder_fti.c b/src/rotaryencoder/rotaryencoder_fti.c index df999597..2f5e2395 100644 --- a/src/rotaryencoder/rotaryencoder_fti.c +++ b/src/rotaryencoder/rotaryencoder_fti.c @@ -28,7 +28,7 @@ #include #include "upm_fti.h" -#include "upm_sensor.h" +#include "fti/upm_sensor.h" /** * This file implements the Function Table Interface (FTI) for this sensor diff --git a/src/rsc/CMakeLists.txt b/src/rsc/CMakeLists.txt index cf090eb9..d59a1da1 100644 --- a/src/rsc/CMakeLists.txt +++ b/src/rsc/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME rsc CPP_HDR rsc.hpp CPP_SRC rsc.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/servo/CMakeLists.txt b/src/servo/CMakeLists.txt index 61928a66..592c33dc 100644 --- a/src/servo/CMakeLists.txt +++ b/src/servo/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME servo CPP_SRC servo.cxx es08a.cxx es9257.cxx FTI_SRC es08a_fti.c es9257_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/sht1x/CMakeLists.txt b/src/sht1x/CMakeLists.txt index 26c0e517..5b417976 100644 --- a/src/sht1x/CMakeLists.txt +++ b/src/sht1x/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME sht1x CPP_SRC sht1x.cxx FTI_SRC sht1x_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/si1132/javaupm_si1132.i b/src/si1132/javaupm_si1132.i index ae9f14b3..01d17138 100644 --- a/src/si1132/javaupm_si1132.i +++ b/src/si1132/javaupm_si1132.i @@ -1,4 +1,9 @@ -%module(directors="1") javaupm_si1132 +#ifdef ANDROID + %module javaupm_si1132 +#else + %module(directors="1") javaupm_si1132 +#endif + %include "../upm.i" %include "../interfaces/javaupm_iLightSensor.i" diff --git a/src/si7005/mraa-utils.cxx b/src/si7005/mraa-utils.cxx index b0e9d92c..4d235106 100644 --- a/src/si7005/mraa-utils.cxx +++ b/src/si7005/mraa-utils.cxx @@ -22,6 +22,8 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #include "mraa-utils.hpp" #include "mraa/gpio.hpp" diff --git a/src/speaker/CMakeLists.txt b/src/speaker/CMakeLists.txt index fdcdee54..18a08f09 100644 --- a/src/speaker/CMakeLists.txt +++ b/src/speaker/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME speaker CPP_SRC speaker.cxx # FTI_SRC speaker_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/ssd1351/ssd1351.hpp b/src/ssd1351/ssd1351.hpp index a1c88421..5da6926f 100644 --- a/src/ssd1351/ssd1351.hpp +++ b/src/ssd1351/ssd1351.hpp @@ -27,7 +27,6 @@ #include -#include #include #include #include "ssd1351_gfx.hpp" diff --git a/src/stepmotor/CMakeLists.txt b/src/stepmotor/CMakeLists.txt index e46388fa..997217f6 100644 --- a/src/stepmotor/CMakeLists.txt +++ b/src/stepmotor/CMakeLists.txt @@ -1,6 +1,9 @@ -set (libname "stepmotor") -set (libdescription "Stepper Motor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) -target_link_libraries(${libname} rt) +# Currently no librt in android +if (NOT ANDROID) + set (libname "stepmotor") + set (libdescription "Stepper Motor") + set (module_src ${libname}.cxx) + set (module_hpp ${libname}.hpp) + upm_module_init(mraa) + target_link_libraries(${libname} rt) +endif (NOT ANDROID) diff --git a/src/temperature/temperature_fti.c b/src/temperature/temperature_fti.c index 6a1da381..19ddd52b 100644 --- a/src/temperature/temperature_fti.c +++ b/src/temperature/temperature_fti.c @@ -29,7 +29,7 @@ #include "temperature.h" #include "upm_fti.h" -#include "upm_sensor.h" +#include "fti/upm_sensor.h" /** * This file implements the Function Table Interface (FTI) for this sensor diff --git a/src/tsl2561/CMakeLists.txt b/src/tsl2561/CMakeLists.txt index 0e6f857e..9fe0d994 100644 --- a/src/tsl2561/CMakeLists.txt +++ b/src/tsl2561/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME tsl2561 CPP_SRC tsl2561.cxx FTI_SRC tsl2561_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/uartat/CMakeLists.txt b/src/uartat/CMakeLists.txt index ef7b3764..4bd5ed74 100644 --- a/src/uartat/CMakeLists.txt +++ b/src/uartat/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME uartat CPP_HDR uartat.hpp CPP_SRC uartat.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/uln200xa/CMakeLists.txt b/src/uln200xa/CMakeLists.txt index 4d7cd75c..ca30d863 100644 --- a/src/uln200xa/CMakeLists.txt +++ b/src/uln200xa/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME uln200xa CPP_HDR uln200xa.hpp CPP_SRC uln200xa.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/urm37/CMakeLists.txt b/src/urm37/CMakeLists.txt index 1a3a63c6..a73ad44b 100644 --- a/src/urm37/CMakeLists.txt +++ b/src/urm37/CMakeLists.txt @@ -6,4 +6,4 @@ upm_mixed_module_init (NAME urm37 CPP_SRC urm37.cxx FTI_SRC urm37_fti.c CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c) diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 8ca2e715..da59de8e 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -1,4 +1,6 @@ upm_mixed_module_init (NAME utilities - DESCRIPTION "C Utilities Library" + DESCRIPTION "Utilities Library" + CPP_HDR upm_utilities.hpp + CPP_SRC upm_utilities.cxx C_HDR upm_utilities.h C_SRC upm_utilities.c) diff --git a/src/utilities/javaupm_utilities.i b/src/utilities/javaupm_utilities.i new file mode 100644 index 00000000..05a8999c --- /dev/null +++ b/src/utilities/javaupm_utilities.i @@ -0,0 +1,12 @@ +%module javaupm_utilities + +%pragma(java) jniclasscode=%{ + static { + try { + System.loadLibrary("javaupm_utilities"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. \n" + e); + System.exit(1); + } + } +%} diff --git a/src/utilities/jsupm_utilities.i b/src/utilities/jsupm_utilities.i new file mode 100644 index 00000000..0493a3b9 --- /dev/null +++ b/src/utilities/jsupm_utilities.i @@ -0,0 +1 @@ +%module jsupm_utilities diff --git a/src/utilities/pyupm_utilities.i b/src/utilities/pyupm_utilities.i new file mode 100644 index 00000000..7b0e4f6e --- /dev/null +++ b/src/utilities/pyupm_utilities.i @@ -0,0 +1 @@ +%module pyupm_utilities diff --git a/src/utilities/upm_utilities.cxx b/src/utilities/upm_utilities.cxx new file mode 100644 index 00000000..e69de29b diff --git a/src/utilities/upm_utilities.hpp b/src/utilities/upm_utilities.hpp new file mode 100644 index 00000000..e69de29b diff --git a/src/wfs/CMakeLists.txt b/src/wfs/CMakeLists.txt index 65f3ca44..897e0042 100644 --- a/src/wfs/CMakeLists.txt +++ b/src/wfs/CMakeLists.txt @@ -5,4 +5,4 @@ upm_mixed_module_init (NAME wfs CPP_HDR wfs.hpp CPP_SRC wfs.cxx CPP_WRAPS_C - REQUIRES mraa) + REQUIRES mraa utilities-c)