smbus
provides access to the System Management bus, over I2C
.
func TestOpen(t *testing.T) {
usr, err := user.Current()
if err != nil {
t.Fatalf("os/user: %v\n", err)
}
if usr.Name != "root" {
t.Skip("need root access")
}
c, err := smbus.Open(0, 0x69)
if err != nil {
t.Fatalf("open error: %v\n", err)
}
defer c.Close()
v, err := c.ReadReg(0x69, 0x1)
if err != nil {
t.Fatalf("read-reg error: %v\n", err)
}
t.Logf("v=%v\n", v)
}