2017-05-29 142 views
1

對於Openhab2,有一個名爲RFXCOM的綁定附加組件。然而,問題是這個附加組件使用的JD2XX與Raspberry Pi的ARM架構不兼容。爲樹莓派編譯JD2XX

我發現與您可以用它來編譯* .so文件的源Github上庫:https://github.com/0x6a77/JD2XX

的Makefile中變化不大使用了正確的Java路徑(祖魯 - 8 armhf嵌入式代替(甲骨文-7)。

運行sudo make jni創建*.so文件,我複製到/usr/lib(Java庫路徑中),但我仍然得到錯誤的樹莓派不能打開共享庫因它是32位的,你如何編譯一個適用於ARM的共享庫和Github存儲庫提供的源代碼。

錯誤消息:

java.lang.UnsatisfiedLinkError: 
/var/lib/openhab2/tmp/libjd2xx5892592723514582617.so: 
/var/lib/openhab2/tmp/libjd2xx5892592723514582617.so: cannot open shared object file: 
No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform) 

樹莓裨具有Openhabian全新安裝。

鏈接到該問題在Github上:https://github.com/openhab/openhab2-addons/issues/2316#issuecomment-304795652

編輯:

11:00:52.291 [ERROR] [rnal.discovery.RFXComBridgeDiscovery] - Error occurred during discovery 
java.io.IOException: device not found (2) 
    at jd2xx.JD2XX.listDevices(Native Method) 
    at jd2xx.JD2XX.listDevicesByDescription(JD2XX.java:785) 
    at org.openhab.binding.rfxcom.internal.discovery.RFXComBridgeDiscovery.discoverRfxcom(RFXComBridgeDiscovery.java:89) 
    at org.openhab.binding.rfxcom.internal.discovery.RFXComBridgeDiscovery.startScan(RFXComBridgeDiscovery.java:66) 
    at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:199) 
    at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:382) 
    at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:358) 
    at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:216) 
    at org.eclipse.smarthome.io.rest.core.discovery.DiscoveryResource.scan(DiscoveryResource.java:84) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_121] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_121] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_121] 
    at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_121] 
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)[157:org.glassfish.jersey.core.jersey-common:2.22.2] 
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)[158:org.glassfish.jersey.core.jersey-server:2.22.2] 
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)[155:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2] 
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)[155:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2] 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)[155:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2] 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)[155:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2] 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)[155:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2] 
    at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76)[10:com.eclipsesource.jaxrs.publisher:5.3.1.201602281253] 
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[81:org.eclipse.jetty.servlet:9.2.19.v20160908] 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[81:org.eclipse.jetty.servlet:9.2.19.v20160908] 
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[172:org.ops4j.pax.web.pax-web-jetty:4.3.0] 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[79:org.eclipse.jetty.security:9.2.19.v20160908] 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[172:org.ops4j.pax.web.pax-web-jetty:4.3.0] 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[81:org.eclipse.jetty.servlet:9.2.19.v20160908] 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[172:org.ops4j.pax.web.pax-web-jetty:4.3.0] 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.Server.handle(Server.java:499)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[80:org.eclipse.jetty.server:9.2.19.v20160908] 
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[72:org.eclipse.jetty.io:9.2.19.v20160908] 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[83:org.eclipse.jetty.util:9.2.19.v20160908] 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[83:org.eclipse.jetty.util:9.2.19.v20160908] 
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_121] 
11:01:02.868 [WARN ] [e.sshd.server.channel.ChannelSession] - Unknown pty opcode value: 42 
+0

是您的文件名libjd2xx5892592723514582617.so?我可以在Makefile中看到共享庫libjd2xx.so的文件名。告訴我如果在測試目錄中使用TestListener.sh會發生什麼情況?我認爲這是一個LD_LIBRARY_PATH或java.library.path問題。 – tommybee

+0

共享庫只有在openhab2複製後纔會調用libjd2xx.so獲取一些數字後綴。我將它複製到/ usr/lib /這是路徑和chmod 755以便能夠讀取它。你是什​​麼意思TestListener? – Emptyless

+0

那麼,不要介意https://github.com/0x6a77/JD2XX/tree/master/jd2xx/test下的TestListener.sh。你可以試試這個腳本嗎? java -Xcheck:jni -Djava.library.path =「你的lib路徑到哪裏」-cp「/ jd2xx.jar到哪裏:「TestListener – tommybee

回答

1

在JD2XX.java文件,你可以看到機制是如何加載一個dll,這樣或一些其他類型的庫取決於操作系統。

static { 
    String dataModel = System.getProperty("sun.arch.data.model"); 
    String osName = System.getProperty("os.name").toLowerCase();; 

    StringBuilder lib = new StringBuilder("/jni/"); 

    if (osName.contains("win")) 
     lib.append("win/"); 
    else if (osName.contains("linux")) 
     lib.append("linux/"); 
    else if (osName.contains("mac")) 
     lib.append("mac/"); 
    else 
     throw new UnsatisfiedLinkError("Loading JD2XX JNI: Unsupported operating system ("+osName+")"); 

    if (dataModel.equals("32")) 
     lib.append("x86_32/"); 
    else if (dataModel.equals("64")) 
     lib.append("x86_64/"); 
    else 
     throw new UnsatisfiedLinkError("Loading JD2XX JNI: Unknown runtime data model ("+dataModel+")"); 

    if (osName.contains("win")) 
     lib.append("jd2xx.dll"); 
    else if (osName.contains("linux")) 
     lib.append("libjd2xx.so"); 
    else if (osName.contains("mac")) 
     lib.append("libjd2xx.jnilib"); 

    try { 
     NativeUtils.loadLibraryFromJar(lib.toString()); 
    } catch (IOException e) { 
     throw new UnsatisfiedLinkError(e.getMessage()); 
    } 
} 

從NativeUtils的loadLibraryFromJar方法創建臨時目錄和操作系統複製正確的庫來臨時目錄然後最終調用System.load方法。 因此,我認爲如果可能的話,您應該修改源代碼的這一部分,如下所示。

static 
{ 
    System.load("/var/lib/openhab2/tmp/libjd2xx5892592723514582617.so"); 
} 

static 
{ 
    System.load("/usr/lib/libjd2xx5892592723514582617.so"); 
} 

有幾種方法,使這項工作的工作重新設置「的java.library.path」以第一指示/ usr/lib目錄,然後使用下面的代碼。

或者您可以將庫名稱libjd2xx5892592723514582617.so重命名爲/ usr/lib中的libjd2xx.so,它通常位於'LD_LIBRARY_PATH'變量中。

然後,我們在JD2XX.java代碼可以用來代替,

static 
{ 
    System.loadLibrary("jd2xx"); 
} 

我認爲它的工作原理..

+0

你對錯誤來自何處是正確的,我重新編譯了* .so和* .jar,解決了它,所以我會給予你賞金,但是我得到一個新的錯誤,但是你解決了問題,所以我會授予你的賞金新的錯誤是在原來的帖子如果你還有第二個備用:-) – Emptyless

+0

好吧,先謝謝你。我發現這篇文章fot你在https:// github .com/openhab/openhab2-addons/issues/1312。首先你必須遵循pdf文件http://www.ftdichip.com/Support/Documents/AppNotes/AN_220_FTDI_Drivers_Installation_Guide_for_Linux.pdf然後,如果指令不起作用,然後嘗試獲得usb掛載點755許可sudo chmod 777/dev/ttyUSB0。你能告訴我在完成所有這些後發生了什麼嗎? – tommybee

+0

Nope都沒有工作,完全相同的堆棧跟蹤。 ttyUSB0設備。 – Emptyless