mirror of
https://github.com/kidoman/embd
synced 2025-07-04 04:17:41 +02:00
Merge 780d9e92ac
into d3d8c0c5c6
This commit is contained in:
commit
daeb225a4c
1 changed files with 14 additions and 0 deletions
|
@ -63,7 +63,21 @@ func (p *digitalPin) init() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *digitalPin) isExported() bool {
|
||||
if _, err := os.Stat(p.basePath()); err == nil {
|
||||
return true
|
||||
} else if os.IsNotExist(err) {
|
||||
return false
|
||||
} else {
|
||||
// unknown
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (p *digitalPin) export() error {
|
||||
if p.isExported() {
|
||||
return nil
|
||||
}
|
||||
exporter, err := os.OpenFile("/sys/class/gpio/export", os.O_WRONLY, os.ModeExclusive)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue