spitest

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package spitest is meant to be used to test drivers over a fake SPI port.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	spi.PortCloser
}

Log logs all operations done on an spi.PortCloser.

func (*Log) Close

func (l *Log) Close() error

Close implements spi.PortCloser.

func (*Log) Connect

func (l *Log) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Log) LimitSpeed

func (l *Log) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

type LogConn

type LogConn struct {
	spi.Conn
}

LogConn logs all operations done on an spi.Conn.

func (*LogConn) Tx

func (l *LogConn) Tx(w, r []byte) error

Tx implements spi.Conn.

func (*LogConn) TxPackets

func (l *LogConn) TxPackets(p []spi.Packet) error

TxPackets is not yet implemented.

type Playback

type Playback struct {
	conntest.Playback
	CLKPin      gpio.PinIO
	MOSIPin     gpio.PinIO
	MISOPin     gpio.PinIO
	CSPin       gpio.PinIO
	Initialized bool
}

Playback implements spi.PortCloser and plays back a recorded I/O flow.

While "replay" type of unit tests are of limited value, they still present an easy way to do basic code coverage.

func (*Playback) CLK

func (p *Playback) CLK() gpio.PinOut

CLK implements spi.Pins.

func (*Playback) CS

func (p *Playback) CS() gpio.PinOut

CS implements spi.Pins.

func (*Playback) Close

func (p *Playback) Close() error

Close implements spi.PortCloser.

Close() verifies that all the expected Ops have been consumed.

func (*Playback) Connect

func (p *Playback) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Playback) LimitSpeed

func (p *Playback) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

func (*Playback) MISO

func (p *Playback) MISO() gpio.PinIn

MISO implements spi.Pins.

func (*Playback) MOSI

func (p *Playback) MOSI() gpio.PinOut

MOSI implements spi.Pins.

type Record

type Record struct {
	sync.Mutex
	Port        spi.PortCloser // Port can be nil if only writes are being recorded.
	Ops         []conntest.IO
	Initialized bool
}

Record implements spi.PortCloser that records everything written to it.

This can then be used to feed to Playback to do "replay" based unit tests.

func (*Record) CLK

func (r *Record) CLK() gpio.PinOut

CLK implements spi.Pins.

func (*Record) CS

func (r *Record) CS() gpio.PinOut

CS implements spi.Pins.

func (*Record) Close

func (r *Record) Close() error

Close implements spi.PortCloser.

func (*Record) Connect

func (r *Record) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Record) LimitSpeed

func (r *Record) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

func (*Record) MISO

func (r *Record) MISO() gpio.PinIn

MISO implements spi.Pins.

func (*Record) MOSI

func (r *Record) MOSI() gpio.PinOut

MOSI implements spi.Pins.

func (*Record) String

func (r *Record) String() string

type RecordRaw

type RecordRaw struct {
	conntest.RecordRaw
	Initialized bool
}

RecordRaw implements spi.PortCloser.

It sends everything written to it to W.

func NewRecordRaw

func NewRecordRaw(w io.Writer) *RecordRaw

NewRecordRaw is a shortcut to create a RecordRaw

func (*RecordRaw) Close

func (r *RecordRaw) Close() error

Close is a no-op.

func (*RecordRaw) Connect

func (r *RecordRaw) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect is a no-op.

func (*RecordRaw) LimitSpeed

func (r *RecordRaw) LimitSpeed(f physic.Frequency) error

LimitSpeed is a no-op.

Jump to

Keyboard shortcuts

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