Documentation ¶
Index ¶
- Constants
- Variables
- func IsIDRestricted(canId uint16) bool
- type Bus
- type BusManager
- func (bm *BusManager) Bus() Bus
- func (bm *BusManager) Error() uint16
- func (bm *BusManager) Handle(frame Frame)
- func (bm *BusManager) Process() error
- func (bm *BusManager) Send(frame Frame) error
- func (bm *BusManager) SetBus(bus Bus)
- func (bm *BusManager) Subscribe(ident uint32, mask uint32, rtr bool, callback FrameListener) error
- type Frame
- type FrameListener
Constants ¶
View Source
const ( CanErrorTxWarning = 0x0001 // CAN transmitter warning CanErrorTxPassive = 0x0002 // CAN transmitter passive CanErrorTxBusOff = 0x0004 // CAN transmitter bus off CanErrorTxOverflow = 0x0008 // CAN transmitter overflow CanErrorPdoLate = 0x0080 // TPDO is outside sync window CanErrorRxWarning = 0x0100 // CAN receiver warning CanErrorRxPassive = 0x0200 // CAN receiver passive CanErrorRxOverflow = 0x0800 // CAN receiver overflow CanErrorWarnPassive = 0x0303 // Combination CanRtrFlag uint32 = 0x40000000 CanSffMask uint32 = 0x000007FF )
Variables ¶
View Source
var ( ErrIllegalArgument = errors.New("error in function arguments") ErrOutOfMemory = errors.New("memory allocation failed") ErrTimeout = errors.New("function timeout") ErrIllegalBaudrate = errors.New("illegal baudrate passed to function") ErrRxOverflow = errors.New("previous message was not processed yet") ErrRxPdoOverflow = errors.New("previous PDO was not processed yet") ErrRxMsgLength = errors.New("wrong receive message length") ErrRxPdoLength = errors.New("wrong receive PDO length") ErrTxOverflow = errors.New("previous message is still waiting, buffer full") ErrTxPdoWindow = errors.New("synchronous TPDO is outside window") ErrTxUnconfigured = errors.New("transmit buffer was not configured properly") ErrOdParameters = errors.New("error in Object Dictionary parameters") ErrDataCorrupt = errors.New("stored data are corrupt") ErrCRC = errors.New("crc does not match") ErrTxBusy = errors.New("sending rejected because driver is busy. Try again") ErrWrongNMTState = errors.New("command can't be processed in the current state") ErrSyscall = errors.New("syscall failed") ErrInvalidState = errors.New("driver not ready") ErrNodeIdUnconfiguredLSS = errors.New("node-id is in LSS unconfigured state. If objects are handled properly, this may not be an error") )
Functions ¶
func IsIDRestricted ¶ added in v1.2.0
Types ¶
type Bus ¶
type Bus interface { Connect(...any) error // Connect to the CAN bus Disconnect() error // Disconnect from CAN bus Send(frame Frame) error // Send a frame on the bus Subscribe(callback FrameListener) error // Subscribe to all received CAN frames }
A CAN Bus interface
type BusManager ¶
type BusManager struct {
// contains filtered or unexported fields
}
Bus manager is a wrapper around the CAN bus interface Used by the CANopen stack to control errors, callbacks for specific IDs, etc.
func NewBusManager ¶
func NewBusManager(bus Bus) *BusManager
func (*BusManager) Bus ¶
func (bm *BusManager) Bus() Bus
func (*BusManager) Handle ¶
func (bm *BusManager) Handle(frame Frame)
Implements the FrameListener interface This handles all received CAN frames from Bus
func (*BusManager) Process ¶ added in v1.2.0
func (bm *BusManager) Process() error
This should be called cyclically to update errors
func (*BusManager) Send ¶
func (bm *BusManager) Send(frame Frame) error
Send a CAN message Limited error handling
func (*BusManager) Subscribe ¶
func (bm *BusManager) Subscribe(ident uint32, mask uint32, rtr bool, callback FrameListener) error
Subscribe to a specific CAN ID
type FrameListener ¶
type FrameListener interface {
Handle(frame Frame)
}
Interface for handling a received CAN frame
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
master
Example of master usage
|
Example of master usage |
internal
|
|
pkg
|
|
can/kvaser
provide fallback when not compiling kvaser
|
provide fallback when not compiling kvaser |
network
This package is a pure golang implementation of the CANopen protocol
|
This package is a pure golang implementation of the CANopen protocol |
Click to show internal directories.
Click to hide internal directories.