1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 04:40:04 +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"
"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
}