1
0
mirror of https://github.com/kidoman/embd synced 2024-06-01 00:28:06 +02:00

gpio: fix a bug which prevented digital pins reads from working correctly

when reading from the value file, it is important to seek back to the front
so that we get the fresh values from the kernel driver for every new read
This commit is contained in:
Kunal Powar 2014-04-05 01:28:15 +05:30
parent fc887282bf
commit a6e3902eb0

View File

@ -117,6 +117,7 @@ func (p *digitalPin) Read() (int, error) {
if _, err := p.val.Read(buf); err != nil { if _, err := p.val.Read(buf); err != nil {
return 0, err return 0, err
} }
p.val.Seek(0, 0)
var val int var val int
if buf[0] == '1' { if buf[0] == '1' {
val = 1 val = 1