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

Give rpi some time to link digital pin property #53

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

Conversation

wujiang
Copy link
Contributor

@wujiang wujiang commented Jan 21, 2016

It looks like Raspberry pi needs some time to get a digital pin link properly after it is being exported.

Sample code to run:

package main

import (
        "fmt"

        "github.com/kidoman/embd"
         _ "github.com/kidoman/embd/host/rpi"
)

func main() {
        defer embd.CloseGPIO()
        fmt.Println(embd.SetDirection(10, embd.Out))
}
  • before the change, the output is open /sys/class/gpio/gpio10/direction: permission denied
  • after the change, the output is <nil>

Close #52

It looks like Raspberry pi needs some time to get a digital pin
link properly after it is being exported.

Sample code to run:

```go
package main

import (
        "fmt"

        "github.com/kidoman/embd"
         _ "github.com/kidoman/embd/host/rpi"
)

func main() {
        defer embd.CloseGPIO()
        fmt.Println(embd.SetDirection(10, embd.Out))
}

```

- before the change, the output is:
`open /sys/class/gpio/gpio10/direction: permission denied`

- after the change, the output is `<nil>`

Close kidoman#52
@tve
Copy link
Contributor

tve commented Aug 27, 2016

IMHO the proper fix would not add a blind delay but use a shorter delay and check the permissions, and then loop until these change. Overall this sucks. Maybe we should add an explicit call to export a list of GPIO pins, this way they could all be exported and then it could wait for the permissions to all get fixed.

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

Successfully merging this pull request may close these issues.

2 participants