I am writing an app in Centos on Raspberry Pi to access the GPIO. I tested using root user and everything works fine.
But when I run this on a user other than root, I have problem accessing the
/sys/class/gpio/export
/sys/class/gpio/gpio17/direction
/sys/class/gpio/gpio17/value
I followed some one suggestions to update 99-gpio.rules and to change owner:
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
Then owner and group are correct. However the GPIO did not seem to be accessed correctly.
Please note the exact same execute image works fine for "root" user.
Can someone help to fix this or point out the limitation of centos cannot access GPIO from non-root user.