jyijyi
August 18, 2015, 7:43am
1
Hi,
I am doing testing on GPIO of AR7550.
By following this page:
viewtopic.php?f=179&t=8351&p=34204&hilit=legato+gpio&sid=5a7904c1438f0e9e89724a437160b193#p34204
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?
davidc
August 18, 2015, 11:03am
2
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 filesandboxed=false
and see if this helps.
I’m not in the office now, but will check my settings when I get back.
Ciao, Dave
davidc
August 19, 2015, 12:00am
3
Hiya,
Just to confirm, I needed to run my application unsandboxed to get access to the hardware ports. Putsandboxed: false
in your ADEF file to allow this.
ciao, Dave
jyijyi
August 19, 2015, 8:43am
4
Hi Dave,
Thx for your help!
It is working now!
Thx!
davidc
August 19, 2015, 10:54am
5
Hiya,
Good to hear that your code is running now.
Thanks for letting us know you got it working.
Ciao, Dave
rio99
January 9, 2017, 11:08am
6
Hello, I have problem with GPIO42, I am trying to export GPIO42 such way:
echo 42 > /sys/class/gpio/export
but Legato responds sh: write error: Device or resource busy
I have already configured GPIO42 using AT command AT+WIOCFG=42,16,1,1,0,0,0
but i still receive this error, how can I unlock GPIO42?
I am also having this problem with “le_gpioPin42, oT0 - GPIO 1 (pin 24)”, both in code and at a simple command line interface:
root@swi-mdm9x15:/sys/class/gpio# echo 42 > export
sh: write error: Device or resource busy
root@swi-mdm9x15:/sys/class/gpio# on WP7504:
My firmware:
Firmware: SWI9X15Y_07.11.09.00 r32989 CARMD-EV-FRMWR1 2016/08/11 18:03:20
Bootloader: SWI9X15Y_07.11.09.00 r32989 CARMD-EV-FRMWR1 2016/08/11 18:03:20
Any Thoughts?