Closed iyanmv closed 5 years ago
The log reports Locked by other application
.
Do you have other applications trying to use the i2c bus (for example the SenseHAT driver and SenseHAT example running at the same time)?
Can you please try to start from a fresh Kura 3.2.0 install and then installing and using only the SenseHAT driver? Try also not to use the pyhton library to avoid interference.
I will try to uninstall the python library and the packages I installed in the Raspbian and try again. That is the first thing I thought, but I don't see how having theses packages installed in the system can lock the i2c bus.
Also, I am not sure to understand the first thing you mentioned. What do you mean with SenseHAT driver and SenseHAT example running at the same time?
I was referring to the Sensehat Example Bundle for Eclipse Kura available from Eclipse Marketplace [1]. Yes, please try to start from a clean setup first, If the problem persists we can investigate further.
[1] https://marketplace.eclipse.org/content/sensehat-example-bundle-eclipse-kura
Ok, I tried the bundle before the driver but I uninstalled it before trying to install the driver. Anyway, I will try tomorrow from a clean setup frist and I will comment here if it works.
Same issue and same execptions in the log from a clean setup.
Ok, I will try to replicate the issue.
More details. I hope they are useful. First time I try to create a new driver after installing the sensehat package I get the following error:
```
2018-05-10 07:32:02,509 [Component Resolve Thread (Bundle 7)] INFO o.e.k.e.d.s.SenseHatDriver - Activating SenseHat Driver...
2018-05-10 07:32:02,510 [Component Resolve Thread (Bundle 7)] INFO o.e.k.e.d.s.SenseHatDriver - Opening Sense Hat...
2018-05-10 07:32:02,578 [Component Resolve Thread (Bundle 7)] ERROR o.e.k.r.s.s.LSM9DS1 - Could not create I2C Device
java.io.IOException: java.io.IOException
at org.eclipse.kura.raspberrypi.sensehat.sensors.KuraI2CDevice.
Then I tried some things.
raspi-config
tool -> Same exception as shown in the first comment.dtparam=i2c_arm=on
while commenting i2c-dev
in /etc/modules
-> Same exceptioni2c-dev
from /etc/modules
while keeping the line dtparam=i2c_arm=on
in /boot/config
-> java.io.IOException: java.io.IOExceptionSo it looks like in a clean install, the raspberry pi 3 does not enable the I2C interface (this agrees with rasp documentation) and I get an IOException but if I load the kernel module, Kura sees the interface locked. Let me know if you can replicate the issue.
Thanks!
Replicated by installing the openjdk-8-jre-headless
package which provides the JVM version you reported.
In my setup the driver works if the oracle-java8-jdk
package is installed, which provides the following java version:
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
There might some issue regarding using the jdk.dio
library either with openjdk
itself or with some JVM version more recent than 1.8.0_65
.
Moreover, I've found this by digging into the jdk.dio
source in Kura repo:
The com.oracle.dio.impl.Handle.tryLock(int)
method, which is called in the code path that leads to the reported exception has the following signature [1]:
public native boolean tryLock(int timeout);
And this is its native implementation [2]:
/*
* Tries locking the device.
* Class: com_oracle_dio_impl_Handle
* Method: tryLock
*/
JNIEXPORT void JNICALL Java_com_oracle_dio_impl_Handle_tryLock
(JNIEnv* env, jobject obj, jint timeout) {
device_reference device = getDeviceReferenceFromHandleObject(env, obj);
if (device != INVALID_DEVICE_REFERENCE) {
// add an implementation
}
}
The native function returns void
instead of a jboolean
, and its implementation looks incomplete. This is quite suspicious.
[1] https://github.com/eclipse/kura/blob/develop/target-platform/jdk.dio-parent/src/dev/src/se/classes/com/oracle/dio/impl/Handle.java#L41 [2] https://github.com/eclipse/kura/blob/develop/target-platform/jdk.dio-parent/src/dev/src/se/native/com/oracle/dio/dio_common.cpp#L458
Ok, great! It works with Oracle's JVM. Thank you very much.
@nicolatimeus Let's document this in the official documentation.
Add the necessary documentation
Component affected:
kura_3.2.0_raspberry-pi-2-3-nn_installer.deb
openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-1~deb9u1-b11) OpenJDK Client VM (build 25.171-b11, mixed mode)
org.eclipse.kura.example.driver.sensehat
Textual description of the issue:
I am trying to use the Sense HAT driver to read data from the environmental sensors and send it to a Kapua instance. I installed the driver mentioned in the form but when I try to add a new driver I get some errors (see kura.log) saying that it is not possible to read or write to the I2C device. I have already enabled the I2C kernel module using the
raspi-config
tool and I confirm that the Sense HAT works because I am able to measure using the python library.