Blockquote
When using unsandboxed application, you need to specify the full path when fopen() .
I did that, but i had the same error (Bad file descriptor).
But I tried (in unsandboxed mode) to use open
instead of fopen
and write
instead of fprintf
and it worked ! If anyone is interested, here is my code:
#include "interfaces.h"
#include "legato.h"
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
COMPONENT_INIT
{
int rc;
int fp = open("/sys/bus/i2c/devices/6-0068/iio:device0/in_accel_sampling_frequency", O_RDWR);
if (fp < 0)
{
LE_ERROR("Error openning the file (errno=%d, err_msg=\"%s\")\n", errno, strerror(errno));
return LE_NOT_FOUND;
}
rc = write(fp, "100", strlen("100"));
if (rc < 0)
{
LE_ERROR("Error writing accelerometer configuration (errno=%d, err_msg=\"%s\")\n", errno,strerror(errno));
return LE_NOT_POSSIBLE;
}
}
Keep in mind your app needs to be in unsandboxed mode for this to work !
Thanks for your help, have a good day !