Documentation
¶
Overview ¶
Package canadapter implements the adapter interface for n2k endpoints.
Index ¶
Constants ¶
const MaxFrameNum = 31
MaxFrameNum is the maximum frame number in a multipart NMEA message.
Variables ¶
This section is empty.
Functions ¶
func CanIdFromData ¶
CanIdFromData returns an encoded ID from its inputs.
func NewPacketInfo ¶
func NewPacketInfo(message Frame) pgn.MessageInfo
NewPacketInfo instantiates a new Packet from a canbus Frame and surrounding context.
Types ¶
type CanAdapter ¶
type CanAdapter struct {
// contains filtered or unexported fields
}
CanAdapter instances read canbus frames from its input and outputs complete Packets.
func NewCanAdapter ¶
func NewCanAdapter(log *logrus.Logger) *CanAdapter
NewCanAdapter instantiates a new CanAdapter
func (*CanAdapter) Run ¶
func (c *CanAdapter) Run(wg *sync.WaitGroup) error
Run method kicks off a goroutine that reads messages from the input channel and writes complete packets to the output channel.
func (*CanAdapter) SetInChannel ¶
func (c *CanAdapter) SetInChannel(in chan adapter.Message)
SetInChannel method sets the input channel
func (*CanAdapter) SetOutChannel ¶
func (c *CanAdapter) SetOutChannel(out chan pkt.Packet)
SetOutChannel method sets the output channel
type Frame ¶
type Frame struct { // bit 0-28: CAN identifier (11/29 bit) // bit 29: error message flag (ERR) // bit 30: remote transmision request (RTR) // bit 31: extended frame format (EFF) ID uint32 Length uint8 Flags uint8 Res0 uint8 Res1 uint8 Data [8]uint8 }
Frame defines a canbus wire frame.
func CanFrameFromRaw ¶
CanFrameFromRaw parses an input string into a can.Frame.
type MultiBuilder ¶
type MultiBuilder struct {
// contains filtered or unexported fields
}
MultiBuilder assembles a sequence of packets into a comple Packet. Manages the list of sequences used to combine multipacket PGNs Instantiated by PGNBuilder Uses sequence to do the work we track sequences separately for each nmea source sequence ids are 0-7, so each source can have 8 sequences in simultaneous transmission sequences map[sourceid]map[pgn]map[SeqId]sequence
func NewMultiBuilder ¶
func NewMultiBuilder(log *logrus.Logger) *MultiBuilder
NewMultiBuilder creates a new instance.
func (*MultiBuilder) Add ¶
func (m *MultiBuilder) Add(p *pkt.Packet)
Add method adds a packet to a (new or existing) sequence. if the sequence (and resulting packet) is now complete, delete the sequence.
func (*MultiBuilder) SeqFor ¶
func (m *MultiBuilder) SeqFor(p *pkt.Packet) *sequence
SeqFor method returns the sequence for the specified packet, creating it it needed.