I started experimenting by changing ownership to the /sys/class/gpio tree by placing this in my rc.local:
Which obviously allows you to export a gpio pin.
I ran into the same issue of root ownership of the gpioX nodes that get created when a gpio pin is exported, preventing me from changing it's direction, or value.
After a while, I figured out the right udev incantation, and this is what I have in my udev rules file (99-gpio.rules):
Code: Select all
SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R pi:pi /sys%p'"
The nodes are accessed by:
It has udev change the permissions to the dynamically generated gpioX files, allowing access without sudo, or similar techniques.
You can easily substitute other commands to change the permissions, instead of changing the ownership.
Providing access to www-data, for example, allows direct reading/writing with PHP file commands to manipulate the gpio states, which was my goal.
Just another way to have fun with the Raspberry Pi. Thanks Eben!
I hope that someone finds this helpful.