AnsweredAssumed Answered

access error i2c device file

Question asked by jan mennen on Sep 11, 2019
Latest reply on Sep 16, 2019 by jan mennen

I  get EACCESS error when opening i2c-2 device file when using Android-NDK build and called via JNI

When using i2c tools i don't have this problem.

 

int i2cbus = 2;
sprintf(fileName, "/dev/i2c-%d", i2cbus);

if ((file = open(fileName,O_RDWR)) < 0) {
    LOGE("Error opening %s file=%d error=%d", fileName, file, errno);
    if (errno == EACCES) LOGE("Run as root?\n");
    return -1;
}

 

Seems  i have to change the access rights of the device file. How to do this permanently. When i do chmod 666  setting is changed but after reboot it is getting its old value.

 

Does someone knows how to solve this issue

Thanks Jan

Outcomes