canrunner

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, n Node) error

func RunMessageReceiver

func RunMessageReceiver(ctx context.Context, rx FrameReceiver, n Node, c clock.Clock) error

func RunMessageTransmitter

func RunMessageTransmitter(
	ctx context.Context,
	tx FrameTransmitter,
	l sync.Locker,
	m TransmittedMessage,
	c clock.Clock,
) error

Types

type FrameReceiver

type FrameReceiver interface {
	Receive() bool
	Frame() can.Frame
	Err() error
}

FrameReceiver is an interface for the CAN frame receiver used by the runner.

type FrameTransmitter

type FrameTransmitter interface {
	TransmitFrame(context.Context, can.Frame) error
}

FrameTransmitter is an interface for the the CAN frame transmitter used by the runner.

type Node

type Node interface {
	sync.Locker
	Connect() (net.Conn, error)
	Descriptor() *descriptor.Node
	TransmittedMessages() []TransmittedMessage
	ReceivedMessage(id uint32) (ReceivedMessage, bool)
}

Node is an interface for a CAN node to be run by the runner.

type ReceivedMessage

type ReceivedMessage interface {
	generated.Message
	// SetReceiveTime sets the time the message was last received.
	SetReceiveTime(time.Time)
	// AfterReceiveHook returns a function to be called after the message has been received.
	//
	// If the hook returns an error, the receiver will halt.
	AfterReceiveHook() func(context.Context) error
}

ReceivedMessage is an interface for a message to be received by the runner.

type TransmittedMessage

type TransmittedMessage interface {
	generated.Message
	// SetTransmitTime sets the time the message was last transmitted.
	SetTransmitTime(time.Time)
	// IsCyclicTransmissionEnabled returns true when cyclic transmission is enabled.
	IsCyclicTransmissionEnabled() bool
	// WakeUpChan returns a channel for waking up and checking if cyclic transmission is enabled.
	WakeUpChan() <-chan struct{}
	// TransmitEventChan returns channel for event-based transmission of the message.
	TransmitEventChan() <-chan struct{}
	// BeforeTransmitHook returns a function to be called before the message is transmitted.
	//
	// If the hook returns an error, the transmitter halt.
	BeforeTransmitHook() func(context.Context) error
}

TransmittedMessage is an interface for a message to be transmitted by the runner.

Jump to

Keyboard shortcuts

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