kidoman / embd

Embedded Programming Framework in Go
http://embd.kidoman.io
MIT License
1.28k stars 156 forks source link

Give rpi some time to link digital pin property #53

Open wujiang opened 8 years ago

wujiang commented 8 years ago

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))
}

Close #52

tve commented 7 years ago

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.