sysfs

package
v0.0.0-...-21b411a Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2014 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sysfs provides generic access to linux gpio.

It is intended to be used while implementing support for a single board linux computer

Index

Constants

View Source
const (
	IN       = "in"
	OUT      = "out"
	HIGH     = 1
	LOW      = 0
	GPIOPATH = "/sys/class/gpio"
)
View Source
const I2CSlave = 0x0703

Variables

This section is empty.

Functions

func NewI2cDevice

func NewI2cDevice(location string, address byte) (io.ReadWriteCloser, error)

NewI2cDevice creates a new io.ReadWriteCloser with the proper ioctrl given an i2c bus location and device address

func SetFilesystem

func SetFilesystem(f Filesystem)

Override the default filesystem.

func SetSyscall

func SetSyscall(s SystemCaller)

func Syscall

func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)

Types

type DigitalPin

type DigitalPin interface {
	Unexport() error
	Export() error
	Read() (int, error)
	Direction(string) error
	Write(int) error
}

func NewDigitalPin

func NewDigitalPin(pin int, v ...string) DigitalPin

NewDigitalPin returns a DigitalPin given the pin number and an optional sysfs pin label. If no label is supplied the default label will prepend "gpio" to the pin number, eg. a pin number of 10 will have a label of "gpio10"

type File

type File interface {
	Write(b []byte) (n int, err error)
	WriteString(s string) (ret int, err error)
	Sync() (err error)
	Read(b []byte) (n int, err error)
	ReadAt(b []byte, off int64) (n int, err error)
	Fd() uintptr
	Close() error
}

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (file File, err error)

Open a file the same as os.OpenFile().

type Filesystem

type Filesystem interface {
	OpenFile(name string, flag int, perm os.FileMode) (file File, err error)
}

type MockFile

type MockFile struct {
	Contents string
	Seq      int // When this file was last written or read.
	Opened   bool
	Closed   bool
	// contains filtered or unexported fields
}

A simple mock file that contains a single string. Any write overwrites, and any read returns from the start.

func (*MockFile) Close

func (f *MockFile) Close() error

func (*MockFile) Fd

func (f *MockFile) Fd() uintptr

func (*MockFile) Read

func (f *MockFile) Read(b []byte) (n int, err error)

func (*MockFile) ReadAt

func (f *MockFile) ReadAt(b []byte, off int64) (n int, err error)

func (*MockFile) Sync

func (f *MockFile) Sync() (err error)

func (*MockFile) Write

func (f *MockFile) Write(b []byte) (n int, err error)

func (*MockFile) WriteString

func (f *MockFile) WriteString(s string) (ret int, err error)

type MockFilesystem

type MockFilesystem struct {
	Seq   int // Increases with each write or read.
	Files map[string]*MockFile
}

A mock filesystem of simple files.

func NewMockFilesystem

func NewMockFilesystem(files []string) *MockFilesystem

func (*MockFilesystem) Add

func (fs *MockFilesystem) Add(name string) *MockFile

func (*MockFilesystem) OpenFile

func (fs *MockFilesystem) OpenFile(name string, flag int, perm os.FileMode) (file File, err error)

type MockSyscall

type MockSyscall struct{}

func (*MockSyscall) Syscall

func (sys *MockSyscall) Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)

type NativeFilesystem

type NativeFilesystem struct{}

Filesystem that opens real files on the host.

func (*NativeFilesystem) OpenFile

func (fs *NativeFilesystem) OpenFile(name string, flag int, perm os.FileMode) (file File, err error)

type NativeSyscall

type NativeSyscall struct{}

func (*NativeSyscall) Syscall

func (sys *NativeSyscall) Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)

type SystemCaller

type SystemCaller interface {
	Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
}

Jump to

Keyboard shortcuts

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