mirror of
https://github.com/kidoman/embd
synced 2025-07-04 20:37:46 +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:
parent
fc887282bf
commit
a6e3902eb0
1 changed files with 1 additions and 0 deletions
|
@ -117,6 +117,7 @@ func (p *digitalPin) Read() (int, error) {
|
|||
if _, err := p.val.Read(buf); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
p.val.Seek(0, 0)
|
||||
var val int
|
||||
if buf[0] == '1' {
|
||||
val = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue