From a6e3902eb0adf5d6043f23d863e4a25b3a400096 Mon Sep 17 00:00:00 2001 From: Kunal Powar Date: Sat, 5 Apr 2014 01:28:15 +0530 Subject: [PATCH] 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 --- digitalpin.go | 1 + 1 file changed, 1 insertion(+) diff --git a/digitalpin.go b/digitalpin.go index 8fffe07..4843743 100644 --- a/digitalpin.go +++ b/digitalpin.go @@ -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