davecheney / gpio

GPIO for Go
BSD 2-Clause "Simplified" License
228 stars 52 forks source link

Get() doesnt work #18

Closed vb4life closed 9 years ago

vb4life commented 9 years ago
func (p *pin) Get() bool {
    bytes := make([]byte, 1)
    _, p.err = p.valueFile.Read(bytes)
    return bytes[0] != 0
}

..should be...

func (p *pin) Get() bool {
    bytes := make([]byte, 1)
    _, p.err = p.valueFile.ReadAt(bytes, 0)
    return bytes[0] != 0
}

The read must be from the start of the file...

vb4life commented 9 years ago

Oh, and the result is the ASCII character "1" or "0", which means that the line return bytes[0] != 0 should be return bytes[0] != 48