Raspberry can't access /dev/mem

坚强是说给别人听的谎言 提交于 2019-12-24 18:10:28

问题


I have installed Raspbian on my Raspberry and added in:

  1. /etc/rc.local:

     chown /dev/ttyUSB0 #to allow current user to use 3G modem
    
  2. /etc/sudoers:

     raspbian ALL=NOPASSWD: ALL
    
  3. And for autologin:

     1:2345:respawn:/sbin/getty --autologin raspbian --noclear 38400 tty1
    

Before I can use GPIO from Python to write to GPIO pins.

Now when I try to run with sudo my Python script I receive an exception where is write that I can't access /dev/mem

I tried to add "raspbian" user to group "kmem" but don't works.

I tried to remove autologin and sudo without password, but also don't works.

I tried with WiringPi from C, and with WiringPi works.

Please help me to find a solution to use GPIO from python.


回答1:


I found the problem.

I forgot about:

  GPIO.setup(<PIN>, <MODE>)

And without this Python throws and exception where write to try to run code with root.



来源:https://stackoverflow.com/questions/19469825/raspberry-cant-access-dev-mem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!