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
- func NewI2cDevice(location string, address byte) (io.ReadWriteCloser, error)
- func SetFilesystem(f Filesystem)
- func SetSyscall(s SystemCaller)
- func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
- type DigitalPin
- type File
- type Filesystem
- type MockFile
- func (f *MockFile) Close() error
- func (f *MockFile) Fd() uintptr
- func (f *MockFile) Read(b []byte) (n int, err error)
- func (f *MockFile) ReadAt(b []byte, off int64) (n int, err error)
- func (f *MockFile) Sync() (err error)
- func (f *MockFile) Write(b []byte) (n int, err error)
- func (f *MockFile) WriteString(s string) (ret int, err error)
- type MockFilesystem
- type MockSyscall
- type NativeFilesystem
- type NativeSyscall
- type SystemCaller
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 SetSyscall ¶
func SetSyscall(s SystemCaller)
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 Filesystem ¶
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.
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
type MockSyscall ¶
type MockSyscall struct{}
type NativeFilesystem ¶
type NativeFilesystem struct{}
Filesystem that opens real files on the host.
type NativeSyscall ¶
type NativeSyscall struct{}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.