2

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 :)
KcFnMi
  • 5,516
  • 10
  • 62
  • 136

2 Answers2

1

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/).

Joel C
  • 2,958
  • 2
  • 15
  • 18
  • I call `wiringPiSetupSys` with no problem. But a call to `digitalWrite` has no effect at all. I guess the export isn't being perceived by the user, how can I check that? – KcFnMi Nov 20 '15 at 18:00
1

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

Armali
  • 18,255
  • 14
  • 57
  • 171