Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNI: load ARM sf/hf according to JVM binary. Linux Lines Status Update. #66

Open
wants to merge 1 commit into
base: 2.8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
jSSC-2.8.0 Release version (24.01.2014)
[VinceOPS] jSSC-2.8.0 - First Fork and Changes (28.01.2015)

Essentially working on Linux (PC & ARM), this fork will contain small fixes/changes which match my projetcs requirements.

In this build:
Fixes:
* DSR "off" event (DSR state 0) was not emitted using (PC) Ubuntu 13.10 and (ARM SF) Debian Wheezy.
* Using the current JVM "arm type" (Soft-Float / Hard-Float) to define which library (sf or hf) should be loaded. Indeed, on MULTIARCH systems (like Debian), it is possible to use a Soft-Float JVM whereas the rootfs is Hard-Float. Reading /proc/self/exe ELF format tells what is the rootfs "arm type", not the JVM (loading an ARMHF library with an ARMSF JVM obviously fails).

Note:
How did I compile the .so libraries on my PC (x86_64) running on Ubuntu 13.10:
* PC (x86_64): g++ jssc.cpp -I/<jdk_path>/include -I/<jdk_path>/include/linux -shared -fPIC -o libjSSC-2.8_x86_64.so
* PC (x86), using g++-multilib: g++ jssc.cpp -I/usr/lib/jvm/jdk1.8.0_25/include -I/usr/lib/jvm/jdk1.8.0_25/include/linux -shared -fPIC -m32 -o libjSSC-2.8_x86.so

* ARM (SF): arm-linux-gnueabi-g++ jssc.cpp -I/<jdk_path>/include -I/<jdk_path>/include/linux -shared -o libjSSC-2.8_armsf.so
* ARM (HF): arm-linux-gnueabihf-g++-4.8 jssc.cpp -I/<jdk_path>/include -I/<jdk_path>/include/linux -shared -fPIC -o libjSSC-2.8_armhf.so

Any version of the ARM toolchain > 4.7 was fine.
Optimisation level 2 (-O2).





============= Previous Builds ==============

///////////////////////////////////////////
//jSSC-2.8.0 Release version (24.01.2014)//
///////////////////////////////////////////

This version contains native libs for Windows(x86, x86-64), Linux(x86, x86-64, ARM soft & hard float), Solaris(x86, x86-64), Mac OS X(x86, x86-64, PPC, PPC64).
All native libs contains in the jssc.jar file and you don't need manage native libs manually.
Expand All @@ -15,8 +43,6 @@ In this build:

With Best Regards, Sokolov Alexey aka scream3r.

============= Previous Builds ==============

///////////////////////////////////////////
//jSSC-2.6.0 Release version (01.06.2013)//
///////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion src/cpp/_nix_based/jssc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,12 @@ JNIEXPORT jboolean JNICALL Java_jssc_SerialNativeInterface_sendBreak
*/
int getLinesStatus(jlong portHandle) {
int statusLines;
ioctl(portHandle, TIOCMGET, &statusLines);

if(ioctl(portHandle, TIOCMGET, &statusLines) != 0) {
// return 0 in case of failure, otherwise statusLines stays unchanged
return 0;
}

return statusLines;
}

Expand Down
3 changes: 2 additions & 1 deletion src/java/jssc/SerialNativeInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ else if(architecture.equals("arm")) {//since 2.1.0
}
else {
try {
Process readelfProcess = Runtime.getRuntime().exec("readelf -A /proc/self/exe");
// get the ELF format of the JVM binary to know which library should be loaded (soft-float or hard-float)
Process readelfProcess = Runtime.getRuntime().exec("readelf -A " + System.getProperty("java.home") + "/bin/java");
BufferedReader reader = new BufferedReader(new InputStreamReader(readelfProcess.getInputStream()));
String buffer = "";
while((buffer = reader.readLine()) != null && !buffer.isEmpty()){
Expand Down
Binary file modified src/java/libs/linux/libjSSC-2.8_armhf.so
100644 → 100755
Binary file not shown.
Binary file modified src/java/libs/linux/libjSSC-2.8_armsf.so
100644 → 100755
Binary file not shown.
Binary file modified src/java/libs/linux/libjSSC-2.8_x86.so
100644 → 100755
Binary file not shown.
Binary file modified src/java/libs/linux/libjSSC-2.8_x86_64.so
100644 → 100755
Binary file not shown.