1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00

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

View File

@ -10,6 +10,7 @@ import (
"os" "os"
"path" "path"
"strconv" "strconv"
"syscall"
"time" "time"
"github.com/kidoman/embd" "github.com/kidoman/embd"
@ -69,6 +70,9 @@ func (p *digitalPin) export() error {
} }
defer exporter.Close() defer exporter.Close()
_, err = exporter.WriteString(strconv.Itoa(p.n)) _, 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 return err
} }