mirror of
https://github.com/kidoman/embd
synced 2024-12-22 21:00:05 +01: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:
parent
fc887282bf
commit
a6e3902eb0
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user