openhab / openhab-syno-spk

openHAB Synology SPK Install Package
Eclipse Public License 2.0
161 stars 42 forks source link

NRJavaSerial.so for RTD1296 SoC #136

Closed karakum closed 5 years ago

karakum commented 6 years ago

I have Synology NAS DS418. There is problem using serial transport in OpenHAB bindings.

To test I use .so lib from OH package (/volume1/@appstore/openHAB/runtime/system/org/openhab/nrjavaserial/3.12.0.OH/nrjavaserial-3.12.0.OH.jar)

I wrote simple test:

package nrjs_test;

import gnu.io.NRSerialPort;

public class Nrjs_test {

    public static void main(String[] args) {
        System.out.println("OS name : "+System.getProperty("os.name"));
        System.out.println("OS arch : "+System.getProperty("os.arch"));

        for (String s : NRSerialPort.getAvailableSerialPorts()) {
            System.out.println("Availible port: " + s);
        }
    }

}

and got output:

OS name : Linux
OS arch : aarch64
java.lang.UnsatisfiedLinkError: /tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: /tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1086)
        at gnu.io.NativeResource.loadResource(NativeResource.java:142)
        at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
        at gnu.io.NativeResource.loadLib(NativeResource.java:60)
        at gnu.io.NativeResource.load(NativeResource.java:28)
        at gnu.io.SerialManager.<init>(SerialManager.java:10)
        at gnu.io.SerialManager.getInstance(SerialManager.java:16)
        at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
        at gnu.io.NRSerialPort.getAvailableSerialPorts(NRSerialPort.java:153)
        at nrjs_test.Nrjs_test.main(Nrjs_test.java:24)
java.lang.UnsatisfiedLinkError: /tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: /tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1086)
        at gnu.io.NativeResource.loadResource(NativeResource.java:142)
        at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
        at gnu.io.NativeResource.loadLib(NativeResource.java:60)
        at gnu.io.NativeResource.load(NativeResource.java:28)
        at gnu.io.SerialManager.<init>(SerialManager.java:10)
        at gnu.io.SerialManager.getInstance(SerialManager.java:16)
        at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
        at gnu.io.NRSerialPort.getAvailableSerialPorts(NRSerialPort.java:153)
        at nrjs_test.Nrjs_test.main(Nrjs_test.java:24)
Exception in thread "main" java.lang.ExceptionInInitializerError
        at gnu.io.NRSerialPort.getAvailableSerialPorts(NRSerialPort.java:153)
        at nrjs_test.Nrjs_test.main(Nrjs_test.java:24)
Caused by: Unable to load deployed native resource
        at gnu.io.NativeResource.loadLib(NativeResource.java:90)
        at gnu.io.NativeResource.load(NativeResource.java:28)
        at gnu.io.SerialManager.<init>(SerialManager.java:10)
        at gnu.io.SerialManager.getInstance(SerialManager.java:16)
        at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
        ... 2 more

I run it under root on my DS418.

Please update library for ARM8 RTD1296 cpu.

wborn commented 5 years ago

I've created the following PR to add arm64 support to nrjavaserial:

https://github.com/NeuronRobotics/nrjavaserial/pull/134

cniweb commented 5 years ago

Thanks @wborn Can I close this issue?

wborn commented 5 years ago

I think it can be closed since it's a nrjavaserial issue that occurs on any openHAB distribution. We just need to build/integrate the nrjavaserial version with the arm64 PR.

See also the community thread about this issue.