Installing rxtx bundle in my Raspberry

3.7k views Asked by At

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: enter image description here

4

There are 4 answers

8
Jorge Martinez On

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.

1
David Woodard On

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.

0
Christian Schneider On

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

0
sabrina2020 On

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.