Added new interfaces bindings

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
Serban Waltter 2018-06-21 16:34:38 +03:00
parent 71a7491702
commit 2ac7778d2d
3 changed files with 15 additions and 1 deletions

View File

@ -23,6 +23,7 @@
*/ */
import upm_sht1x.SHT1X; import upm_sht1x.SHT1X;
import upm_new_interfaces.*;
public class SHT1X_Example public class SHT1X_Example
{ {
@ -32,8 +33,10 @@ public class SHT1X_Example
// Instantiate a SHT1X sensor using D2 as the clock, and D3 as the // Instantiate a SHT1X sensor using D2 as the clock, and D3 as the
// data pin. // data pin.
iTemperature temp = new SHT1X(2, 3);
SHT1X sensor = new SHT1X(2, 3); SHT1X sensor = new SHT1X(2, 3);
// Every 2 seconds, update and print values // Every 2 seconds, update and print values
while (true) while (true)
{ {

View File

@ -531,6 +531,10 @@ function(upm_swig_java)
# target .jar file in the classpath, otherwise this variable will be empty # target .jar file in the classpath, otherwise this variable will be empty
set (INTERFACES_JAR_FILE ${CMAKE_BINARY_DIR}/src/interfaces/upm_interfaces.jar) set (INTERFACES_JAR_FILE ${CMAKE_BINARY_DIR}/src/interfaces/upm_interfaces.jar)
endif () endif ()
if(module_iface)
add_dependencies(javaupm_${libname} javaupm_new_interfaces)
set (NEW_INTERFACES_JAR_FILE ${CMAKE_BINARY_DIR}/interfaces/upm_new_interfaces.jar)
endif()
# For linker to report unresolved symbols. Note, there is currently no test # For linker to report unresolved symbols. Note, there is currently no test
# for linker flags (similar to compile files), so this is it for now. # for linker flags (similar to compile files), so this is it for now.
swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARY} ${JAVA_LIBRARIES} ${libname} -Wl,--unresolved-symbols=report-all) swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARY} ${JAVA_LIBRARIES} ${libname} -Wl,--unresolved-symbols=report-all)
@ -581,7 +585,7 @@ function(upm_swig_java)
add_custom_command (TARGET javaupm_${libname} add_custom_command (TARGET javaupm_${libname}
POST_BUILD POST_BUILD
COMMAND cmake -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname} COMMAND cmake -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}
COMMAND ${JAVAC} *.java -d ${CMAKE_CURRENT_BINARY_DIR} -cp ${INTERFACES_JAR_FILE}:. COMMAND ${JAVAC} *.java -d ${CMAKE_CURRENT_BINARY_DIR} -cp ${INTERFACES_JAR_FILE}:${NEW_INTERFACES_JAR_FILE}:.
COMMAND ${JAR} cf upm_${libname}.jar upm_${libname} COMMAND ${JAR} cf upm_${libname}.jar upm_${libname}
) )

View File

@ -1,10 +1,17 @@
#ifdef SWIGPYTHON
%module (package="pyupm_new_interfaces") sht1x %module (package="pyupm_new_interfaces") sht1x
#endif
%import "interfaces/new_interfaces.i" %import "interfaces/new_interfaces.i"
%include "../common_top.i" %include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */ /* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA #ifdef SWIGJAVA
%typemap(javaimports) SWIGTYPE %{
import upm_new_interfaces.*;
%}
JAVA_JNI_LOADLIBRARY(javaupm_sht1x) JAVA_JNI_LOADLIBRARY(javaupm_sht1x)
#endif #endif
/* END Java syntax */ /* END Java syntax */