can

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: BSD-3-Clause Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPipe

func NewPipe() (Device, Device)

func RegisterDriver

func RegisterDriver(drv Driver)

Types

type Bitrate

type Bitrate int32

type Device

type Device interface {
	Read([]Msg) (n int, err error)

	// Writes a message into the driver transmit buffer.
	// The ownership of the message will not be taken.
	WriteMsg(*Msg) error

	// As an alternative to WriteMsg, Write can be used
	// if more than one message should be handed over
	// to the driver at once (if the driver is able to do that).
	Write([]Msg) (n int, err error)

	ID() string
	Name() Name
	Version() Version

	Close() error
}

The Device interface gives access to a CAN Device. Read and Write calls will block if no messages are available to be read or if the transmit buffer of the driver is full.

func Open

func Open(deviceName string, options ...string) (dev Device, err error)

driverName:deviceName:[,option][,option2]

name Go driver name

type Driver

type Driver interface {
	Name() string
	//	Version() string
	Open(name string, options ...interface{}) (Device, error)
	Scan() []Name
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Flags

type Flags int

Message Flags.

const (
	// message type
	ExtFrame Flags = 1 << iota
	RTRMsg
	StatusMsg

	// if StatusMsg is set:
	ErrorActive
	ErrorPassive
	BusOff
	DataOverrun
	ReceiveBufferOverflow
)

func (Flags) ExtFrame

func (f Flags) ExtFrame() bool

Reports whether the message contains an 29 bit wide, extended indentifier, or a standard 11 bit wide identifier.

func (Flags) IsStatus

func (f Flags) IsStatus() bool

Reports wether the message is a status message, not a data message. In the first case, Msg fields Id, Len and Data should not be interpreted.

func (Flags) Test

func (f Flags) Test(t Flags) bool

type Msg

type Msg struct {
	Id uint32 // The CAN message identifier
	Flags
	Len  int
	Data [8]byte

	Tx struct {
		Delayµs int // The driver shall delay this message.
	}
	Rx struct {
		Time Time // Timestamp
	}
}

Definition of a CAN Message.

type Name

type Name struct {
	ID      string
	Display string
	Device  string
	Driver  string
}

func Scan

func Scan() (list []Name)

func (*Name) Format

func (n *Name) Format(idSep, itemSep, end string) string

func (*Name) String

func (n *Name) String() string

type Termination

type Termination bool

type Time

type Time int64

func Now

func Now() Time

func UnixTimevals

func UnixTimevals(s, µs int32) Time

func (Time) Time

func (t Time) Time() time.Time

func (Time) UnixTimevals

func (t Time) UnixTimevals() (s, µs int32)

type Unversioned

type Unversioned struct{}

func (Unversioned) Name

func (Unversioned) Name() Name

func (Unversioned) Version

func (Unversioned) Version() Version

type Version

type Version struct {
	Device    string
	Driver    string
	Api       string
	SerialNum string
}

Directories

Path Synopsis
cmd
can
drv
A helper package for the various CAN driver interface packages.
A helper package for the various CAN driver interface packages.
all
Convenience package that registers all known drivers.
Convenience package that registers all known drivers.
canrpc
Package canrpc implements net/rpc client and server objects.
Package canrpc implements net/rpc client and server objects.
socketcan Module

Jump to

Keyboard shortcuts

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