[英]wiringPi non-root access to GPIO
From this I though acess to GPIO for non-root users would be possible using wiringPiSetupSys()
but I failed trying that.从这里我虽然可以使用
wiringPiSetupSys()
为非 root 用户访问 GPIO,但我尝试失败。
Actually, if I do setuid on the executable then it works.实际上,如果我在可执行文件上执行 setuid ,那么它就可以工作。 So,
wiringPiSetupSys()
isn't enought?那么,
wiringPiSetupSys()
还不够吗?
$ ./gpio write 4 1 // This don't work :(
# chown root gpioapp
# chmod u+x gpioapp
$ ./gpio write 4 1 // This works :)
According to the GPIO utility documentation , the gpio
utility is designed to be installed as setuid.根据GPIO 实用程序文档,
gpio
实用程序设计为作为 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/ ).一旦它被用于导出引脚(根据
wiringPiSetupSys
要求),您可以以非root 用户身份调用wiringPiSetupSys
(请参阅http://wiringpi.com/reference/setup/ )。
Is your non-root user a member of the gpio group?您的非 root 用户是 gpio 组的成员吗? – Ben Voigt
— 本·沃格特
Yeah, that's the point!是的,这就是重点! It wasn't, just changed (
usermod -a -G gpio myuser
) and now it's working.不是,只是改变了(
usermod -a -G gpio myuser
),现在它可以工作了。 – KcFnMi – KcFnMi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.