smbus

package module
v0.0.0-...-5725b45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: BSD-3-Clause Imports: 5 Imported by: 19

README

smbus

GoDoc

smbus provides access to the System Management bus, over I2C.

Example

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)
}

Documentation

Overview

Package smbus provides access to the System Management bus, over i2c.

http://www.smbus.org/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is connection to a i2c device.

func Open

func Open(bus int, addr uint8) (*Conn, error)

Open opens a connection to the i2c bus number at address addr.

func OpenFile

func OpenFile(bus int) (*Conn, error)

OpenFile opens a connection to the i2c bus number. Users should call SetAddr afterwards to have a properly configured SMBus connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection to the remote i2c device.

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

Read reads data from the remote i2c device into p.

func (*Conn) ReadBlockData

func (c *Conn) ReadBlockData(addr, reg uint8, buf []byte) error

ReadBlockData reads len(buf) data into the byte slice, from the designated register.

func (*Conn) ReadReg

func (c *Conn) ReadReg(addr, reg uint8) (uint8, error)

ReadReg reads a single byte from a designated register.

func (*Conn) ReadWord

func (c *Conn) ReadWord(addr, reg uint8) (uint16, error)

ReadWord reads a 2-bytes word from a designated register.

func (*Conn) SetAddr

func (c *Conn) SetAddr(addr uint8) error

func (*Conn) Write

func (c *Conn) Write(buf []byte) (int, error)

Write sends buf to the remote i2c device. The interpretation of the message is implementation dependant.

func (*Conn) WriteBlockData

func (c *Conn) WriteBlockData(addr, reg uint8, buf []byte) error

WriteBlockData writes the buf byte slice to a designated register.

func (*Conn) WriteByte

func (c *Conn) WriteByte(b byte) (int, error)

WriteByte sends a single byte to the remote i2c device. The interpretation of the message is implementation dependant.

func (*Conn) WriteReg

func (c *Conn) WriteReg(addr, reg, v uint8) error

WriteReg writes a single byte v to a designated register.

func (*Conn) WriteWord

func (c *Conn) WriteWord(addr, reg uint8, v uint16) error

WriteWord writes a 2-bytes word v to a designated register.

Directories

Path Synopsis
sensor
adc101x
Package adc101x provides access to a 10-bit Analog-to-Digital converter.
Package adc101x provides access to a 10-bit Analog-to-Digital converter.
at30tse75x
Package at30tse75x provides access to AT30TSE75x devices.
Package at30tse75x provides access to AT30TSE75x devices.
bme280
Package bme280 provides access to BME280 devices.
Package bme280 provides access to BME280 devices.
hts221
Package hts221 provides access to HTS221 devices.
Package hts221 provides access to HTS221 devices.
sht3x
Package sht3x provides access to SHT3x-D based devices.
Package sht3x provides access to SHT3x-D based devices.
si7021
Package si7021 provides access to SI7021 devices.
Package si7021 provides access to SI7021 devices.
tsl2591
Package tsl2591 provides access to the TSL2591 sensor, over I2C/SMBus for RaspBerry.
Package tsl2591 provides access to the TSL2591 sensor, over I2C/SMBus for RaspBerry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL