entropia / libsocket-can-java

SocketCAN JNI wrapper
MIT License
44 stars 49 forks source link

Java 1.6 compatibility, minor tweak to cansocket.cpp to provide better android build support. #12

Closed a-ross-cohen closed 6 years ago

a-ross-cohen commented 11 years ago

CanSocket.java was edited to remove any java 1.6 incompatibilities. Some of cansocket.cpp needed to be conditionally wrapped in an extern "C" block to get the Android-NDK to build the .so file correctly. Also, a comment has been added to guide anyone else building against the Android-NDK, as it uses an old version of sys/socket.h and needs to be manually remedied to build, at least as of this pull request.

yegorich commented 11 years ago

You don't need to specify AF_CAN or PF_CAN in the source file. It can be made in Android.mk (https://github.com/yegorich/libsocket-can-java/blob/android-port/jni/Android.mk) like this:

PRIVATE_LOCAL_CFLAGS := -O2 -g -W -Wall \ -DSO_RXQ_OVFL=40 \ -DPF_CAN=29 \ -DAF_CAN=PF_CAN

This is also the way can-utils handles this macros, if they are not defined: https://gitorious.org/linux-can/can-utils/source/16c970d40e6c19dde705bad4751bab1a3a4f3a0d:configure.ac

hannes-zz commented 11 years ago

Thanks for the review @yegorich!

@a-ross-cohen Could you make sure the source still works (at least the unit-test) with a non-android setup? I get linking failures because of the rename of LIB_JNI_SOCKETCAN.

Renew the pull-request, I am happy to take it then!