wiringPi非root访问GPIO
wiringPi non-root access to GPIO
来自 this 我虽然可以使用 wiringPiSetupSys()
为非 root 用户访问 GPIO,但我尝试失败了。
实际上,如果我对可执行文件执行 setuid,它就可以工作。那么,wiringPiSetupSys()
还不够吗?
$ ./gpio write 4 1 // This don't work :(
# chown root gpioapp
# chmod u+x gpioapp
$ ./gpio write 4 1 // This works :)
根据 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/).
您的非 root 用户是 gpio 组的成员吗? – 本·沃格特
对,就是这个意思!不是,只是更改了 (usermod -a -G gpio myuser
),现在可以正常使用了。 – KcFnMi
来自 this 我虽然可以使用 wiringPiSetupSys()
为非 root 用户访问 GPIO,但我尝试失败了。
实际上,如果我对可执行文件执行 setuid,它就可以工作。那么,wiringPiSetupSys()
还不够吗?
$ ./gpio write 4 1 // This don't work :(
# chown root gpioapp
# chmod u+x gpioapp
$ ./gpio write 4 1 // This works :)
根据 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/).
您的非 root 用户是 gpio 组的成员吗? – 本·沃格特
对,就是这个意思!不是,只是更改了 (usermod -a -G gpio myuser
),现在可以正常使用了。 – KcFnMi