https://github.com/go-daq/smbus
smbus provides access to the System Management bus over I2C
https://github.com/go-daq/smbus
Last synced: 5 months ago
JSON representation
smbus provides access to the System Management bus over I2C
- Host: GitHub
- URL: https://github.com/go-daq/smbus
- Owner: go-daq
- License: bsd-3-clause
- Created: 2017-01-13T16:39:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-16T17:33:00.000Z (over 5 years ago)
- Last Synced: 2024-06-19T00:38:58.485Z (almost 2 years ago)
- Language: Go
- Size: 18.6 KB
- Stars: 14
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smbus
[](https://godoc.org/github.com/go-daq/smbus)
`smbus` provides access to the [System Management bus](http://www.smbus.org/), over `I2C`.
## Example
[embedmd]:# (smbus_test.go go /func TestOpen/ /\n}/)
```go
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)
}
```