Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpi with sysfs: pin.high() not working when running script with sudo #5

Closed
ramalho opened this issue Apr 5, 2014 · 3 comments
Closed
Labels

Comments

@ramalho
Copy link
Contributor

ramalho commented Apr 5, 2014

$ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pingo
>>> pi = pingo.rpi.RaspberryPi()
>>> led = pi.pins[12]
>>> led.high()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pingo/board.py", line 48, in high
    self.board.set_pin_state(self, HIGH)
  File "pingo/rpi.py", line 95, in set_pin_state
    fp.write(str(state))
IOError: [Errno 1] Operation not permitted

After running the test above, I was able to light up an LED connected to pin 12 (GPIO #18) using these commands:

$ sudo echo 18 > /sys/class/gpio/export
echo: write error: Device or resource busy
$ sudo echo 18 > /sys/class/gpio/unexport
$ sudo echo 18 > /sys/class/gpio/export
$ sudo echo out > /sys/class/gpio/gpio18/direction
$ sudo echo 1 > /sys/class/gpio/gpio18/value
@Vido
Copy link
Contributor

Vido commented Apr 6, 2014

Well,
I had some random: IOError [Errno 16] Device or resource busy
But IOError: [Errno 1] Operation not permitted, had never happend to me, specially on sudo.

I guess our /sys/class/gpio implementation looks quite weak and unstable.
Perhaps it is time to move to RPi.GPIO, or give the good-old C a shoot.

@ramalho
Copy link
Contributor Author

ramalho commented Apr 6, 2014

I still think we should insist with sysfs a little more. I was not very
focused yesterday, and even if RPi.GPIO is better (it probably is), sysfs
is a standard across many boards and we should make it work because
sometimes compiling a C extension in one of these boards is going to be
difficult. We just need some time to code it carefully. For example, it
makes not sense to export all pins if the app will only use a few. And then
we must keep track of which were exported so that only those are
unexported. And we need to improve our tests. Do you know py.test? I want
to start using that. doctest is good to demo/teach the straightforward
cases, for anything else unittest is better and py.test even more.

On Sun, Apr 6, 2014 at 2:05 AM, Lucas Vido notifications@github.com wrote:

Well,
I had some random: IOError [Errno 16] Device or resource busy
But IOError: [Errno 1] Operation not permitted, had never happend to me,
specially on sudo.

I guess our /sys/class/gpio implementation looks quite weak and unstable.
Perhaps it is time to move to RPi.GPIO, or give the good-old C a shoot.


Reply to this email directly or view it on GitHubhttps://github.com/garoa/pingo/issues/5#issuecomment-39658698
.

Luciano Ramalho
Twitter: @ramalhoorg

Professor em: http://python.pro.br
Twitter: @pythonprobr

@ramalho
Copy link
Contributor Author

ramalho commented Apr 18, 2014

For now we have decided to use RPi.GPIO on the Raspberry Pi, instead of sysfs

@ramalho ramalho closed this as completed Apr 18, 2014
@Vido Vido added wontfix and removed wontfix labels Jul 16, 2014
@Vido Vido added the wontfix label Dec 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants