Documentation
¶
Overview ¶
Package canbus is built around the Channel structure, which represents a single canbus channel for sending/receiving CAN frames
Index ¶
Constants ¶
const DefaultBitRate = 250000
DefaultBitRate is the bitrate that Channel defaults to using.
Variables ¶
This section is empty.
Functions ¶
func GetCanInterfaceNameForSpiDevice ¶
GetCanInterfaceNameForSpiDevice returns the can interface name (i.e. can0/can1) for a given spi device (i.e. "spi0.0").
Types ¶
type Channel ¶
type Channel struct { ChannelOptions ChannelOptions // contains filtered or unexported fields }
Channel represents a single canbus channel for sending/receiving CAN frames
func NewChannel ¶
func NewChannel(ctx context.Context, log *logrus.Logger, ChannelOptions ChannelOptions, opts ...ChannelOption) (*Channel, error)
NewChannel returns a Channel object based on the given options. ChannelOptions are required settings, and then you can optionally add more ChannelOption objects for various optional options.
type ChannelOption ¶
type ChannelOption func(*Channel)
ChannelOption is the type used to apply function options to Channel.
func WithBitRate ¶
func WithBitRate(br int32) ChannelOption
WithBitRate overrides the DefaultBitRate set on Channel.
type ChannelOptions ¶
type ChannelOptions struct { CanInterfaceName string MessageHandler can.HandlerFunc }
ChannelOptions is a type that contains required options on a Channel.