gpio: don't fail if pin is already exported

This commit is contained in:
Thorsten von Eicken 2016-08-26 23:02:41 -07:00
parent 938a071c1a
commit 091d6f5588
1 changed files with 4 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"os"
"path"
"strconv"
"syscall"
"time"
"github.com/kidoman/embd"
@ -69,6 +70,9 @@ func (p *digitalPin) export() error {
}
defer exporter.Close()
_, err = exporter.WriteString(strconv.Itoa(p.n))
if e, ok := err.(*os.PathError); ok && e.Err == syscall.EBUSY {
return nil // EBUSY -> the pin has already been exported
}
return err
}