question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Sense HAT driver] Unable to read to I2C device

See original GitHub issue
  • Component affected:

    • Distribution
      • Installer name: kura_3.2.0_raspberry-pi-2-3-nn_installer.deb
      • Platform: Raspberry Pi 3
      • Kura version affected: 3.2.0
      • Java version: 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)
      • Host OS: Raspbian Stretch Lite
    • Add-ons
  • 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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolatimeuscommented, May 10, 2018

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

0reactions
cdealticommented, Sep 24, 2018

Add the necessary documentation

Read more comments on GitHub >

github_iconTop Results From Across the Web

sense hat problem please help - Raspberry Pi Forums
with the sense hat root@raspberrypi:~# hwclock -r hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
Read more >
Raspberry Pi 4 I2C bus not working correctly - Stack Overflow
I tried to use the Raspberry Pi Sense HAT and the SSD1306 OLED display and the PCA9685 Servo Driver with the I2C Bus....
Read more >
Writing to register on I2C device, returns device busy
I am trying to write data to a register on an I2C chip from the Raspberry Pi, when I use i2cdetect I get...
Read more >
RaspberryPi 3 Model B+ and I2C issue - Wolfram Community
Hello,. I have been struggling with SenseHAT and Mathematica. First Mathematica was not able to find SenseHAT at all even than I followed...
Read more >
[PATCH 0/5] Raspberry Pi Sense HAT driver - kernel
[PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver ... < 0) { + dev_err(sensehat->dev, "failed to read from device"); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found