Reputation: 6171
From this I though acess to GPIO for non-root users would be possible using wiringPiSetupSys()
but I failed trying that.
Actually, if I do setuid on the executable then it works. So, wiringPiSetupSys()
isn't enought?
$ ./gpio write 4 1 // This don't work :(
# chown root gpioapp
# chmod u+x gpioapp
$ ./gpio write 4 1 // This works :)
Upvotes: 2
Views: 6680
Reputation: 19395
Is your non-root user a member of the gpio group? – Ben Voigt
Yeah, that's the point! It wasn't, just changed (usermod -a -G gpio myuser
) and now it's working. – KcFnMi
Upvotes: 1
Reputation: 3158
According to the GPIO utility documentation, the gpio
utility is designed to be installed as setuid. Once that has been used to export the pins (as is required by wiringPiSetupSys
), you can call wiringPiSetupSys
as a non-root user (see http://wiringpi.com/reference/setup/).
Upvotes: 1