GPIO access via Legato application

Hi,

I am doing testing on GPIO of AR7550.
By following this page:


https://forum.sierrawireless.com/t/ar7-board-gpio-support/11974/1

I can read the GPIO state via /sys/class/gpio/gpio10/value

However, when i try to access this directory inside legato application,

[code] LE_INFO(“Enter init_gpio”);
if (le_dir_IsDir("/sys/class/gpio/gpio10"))
{
LE_DEBUG(“Gpio already initialized”);
return;
}

   int fd;
   int value;

   fd = open("/sys/class/gpio/gpio10/direction", O_WRONLY);
   if (fd < 0)
   {
      LE_DEBUG("Failed to open gpio10 direction\n");
      return;
   }
   else
   {
      LE_DEBUG("gpio10 direction opened\n");
   }
   write(fd, "in",2);
   close(fd);
       fd = open("/sys/class/gpio/gpio10/value", O_RDONLY);
   	   if (fd < 0)
   	   {
   	      LE_DEBUG("Failed to open gpio10 value\n");
   	      return;
   	   }
   	   else
   	   {
   	      LE_DEBUG("gpio10 value opened\n");
   	   }
   	   read(fd, &value,sizeof(int));
   	   close(fd);
   	 LE_DEBUG("gpio10 value = %d\n",value);[/code]

It always returns “Failed to open gpio10 value”.
Do you know why?

Hiya,

It’s been my experience that you need to be root to get access to the hardware. A Legato application runs sandboxed with a non-root user by default.

Add the following line to your adef file sandboxed=false and see if this helps.

I’m not in the office now, but will check my settings when I get back.

Ciao, Dave

Hiya,

Just to confirm, I needed to run my application unsandboxed to get access to the hardware ports. Put sandboxed: false in your ADEF file to allow this.

ciao, Dave

Hi Dave,

Thx for your help!
It is working now!

Thx!

Hiya,

Good to hear that your code is running now.

Thanks for letting us know you got it working.

Ciao, Dave