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

Wait for sysfs node to ready before access (API BREAK) #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Wait for sysfs node to ready before access (API BREAK) #16

wants to merge 1 commit into from

Conversation

nocko
Copy link
Contributor

@nocko nocko commented Dec 31, 2016

With current versions of sysfs-gpio on Raspberry Pi, the first run of the application would fail (Permission Denied on SYSFS_GPIO_VALUE_PATH); but the second time (or if the pins were already exported); the library works fine.

As it turns out, on Raspberry Pi (Raspbian Jessie); it takes some time for the sysfs nodes under the GPIO pin to have the correct permissions assigned if you're not running your application as root.

Doing a time.sleep(0.5) works, but is dirty. This branch attempts to do it the "Right Way"; BUT that means Controller.alloc_pin() returns a deferred... which breaks existing code.

On the other hand, the raspberry pi may be the most commonly used / available python+GPIO hardware target so having the library work there is good.

@derekstavis
Copy link
Owner

Thanks for the PR @nocko! Good job here! 🍻

I would suggest not breaking the API. We have two ways of doing this:

  • Clone alloc_pin into a new function alloc_pin_deferred
    • Usage: Controller.alloc_pin_deferred(7)
  • Accept a keyword argument like deferred=True in alloc_pin
    • Usage: Controller.alloc_pin(7, deferred=True)

This way we can publish to PyPI and keep compatibility, while allowing new implementations to wait for pin availability. What's your opinion on the more appropriate solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants