Installing rxtx bundle in my Raspberry

老子叫甜甜 提交于 2019-12-20 06:15:32

问题


I want to install an rxtx bundle on my Raspberry Pi the bundle will be running on KURA platform (Equinox is the OSGi container for Kura)

I installed the rxtx native library using: sudo apt-get install librxtx-java

the .so was installed on the directory: /usr/lib/jni/

pi@raspberrypi /usr/lib/jni $ ls
librxtxI2C-2.2pre1.so       librxtxParallel.so     librxtxRS485-2.2pre1.so  librxtxSerial-2.2pre1.so
librxtxI2C.so               librxtxRaw-2.2pre1.so  librxtxRS485.so          librxtxSerial.so
librxtxParallel-2.2pre1.so  librxtxRaw.so  

Then I followed this link to wrappe the rxtx library in a bundle http://rxtx.qbang.org/wiki/index.php/Wrapping_RXTX_in_an_Eclipse_Plugin

I added to the bundle manifest this:

Bundle-NativeCode: /usr/lib/jni/librxtxSerial.so;osname="Linux";processor="armv6l"

cause my os type is linux, my architecture is ARM:

pi@raspberrypi ~ $ cat /proc/sys/kernel/{ostype,osrelease,version}
Linux
3.18.11+
#781 PREEMPT Tue Apr 21 18:02:18 BST 2015

pi@raspberrypi ~ $ arch
armv6l

But still I can't install the bundle, I got this error:

!ENTRY  1 0 2015-06-19 10:19:40.982
!MESSAGE [IAgent][RemoteBundleAdminImpl@17f36b1] [startBundle] Bundle cannot be started: Error[code=-6000;message=Failed to start bundle: The bundle "RXTX_Bundle_1.0.0 [77]" could not be resolved. Reason: No match found for native code: /usr/lib/jni/librxtxSerial.so; processor=armv6l; osname=Linux;details=null]
!STACK 0
org.osgi.framework.BundleException: The bundle "RXTX_Bundle_1.0.0 [77]" could not be resolved. Reason: No match found for native code: /usr/lib/jni/librxtxSerial.so; processor=armv6l; osname=Linux
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
        at org.tigris.mtoolkit.iagent.internal.rpc.RemoteBundleAdminImpl.startBundle(RemoteBundleAdminImpl.java:230)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.tigris.mtoolkit.iagent.internal.pmp.InvocationThread.run(InvocationThread.java:54)
        at org.tigris.mtoolkit.iagent.internal.utils.ThreadPool$Worker.run(ThreadPool.java:179)
        at java.lang.Thread.run(Thread.java:724)

What have I did wrong? Thanks a lot for your help!

Updates after following @Jorge Martinez suggestion: here is my updated line of the manifest:

Bundle-NativeCode: nativelib/librxtxSerial.so;osname="Linux";processor="armv6l"

here is the list of content of my rxtx bundle:


回答1:


Jorge's response is correct. Have you physically examined the bundle being created by Eclipse to confirm your nativelib directory is present? When exporting the bundle from Eclipse, you have to ensure you specify which folders and files are included in the build. This is done by opening the build.properties file and placing a check mark by the folder/files you wish to include.




回答2:


You need to embed native libraries in your bundle (inside the jar or in a fragment).

I.e if you place your library here:

/this/is/yournative/package/librxtxSerial.so

you can use this manifest entry:

Bundle-NativeCode: this/is/yournative/package/librxtxSerial.so;osname="Linux";processor="armv6l"

Note that OSGi loads native libs by extracting them to a temporal folder and then loads them.




回答3:


Use this bundle rxtx osgi. It should contain all you need.




回答4:


Thanks all for your responses! The bundle is Active!

I used this link to get rxtx sources and to compile my native sources: https://blogs.oracle.com/jtc/entry/java_serial_communications_revisited

and I updated the build.properties to include the native library.



来源:https://stackoverflow.com/questions/30936314/installing-rxtx-bundle-in-my-raspberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!