canl2

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package canl2 provides the API for the io4edeg template functionblock

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a client for the canL2

func NewClientFromUniversalAddress

func NewClientFromUniversalAddress(addrOrService string, timeout time.Duration) (*Client, error)

NewClientFromUniversalAddress creates a new canL2 client from addrOrService. If addrOrService is of the form "host:port", it creates the client from that host/port, otherwise it assumes addrOrService is the instance name of a mdns service (without _io4edge_canL2._tcp). The timeout specifies the maximal time waiting for a service to show up. If 0, use default timeout. Not used for "host:port"

func (*Client) Close

func (c *Client) Close()

Close terminates the underlying connection to the functionblock

func (*Client) DownloadConfiguration

func (c *Client) DownloadConfiguration() (*Configuration, error)

DownloadConfiguration reads the template function block configuration

func (*Client) GetCtrlState

func (c *Client) GetCtrlState() (uint32, error)

GetCtrlState returns the current state of the CAN controller The returned values is one of the following:

 fspb == "github.com/ci4rail/io4edge_api/canL2/go/canL2/v1alpha1"
	fspb.ControllerState_CAN_BUS_OFF
	fspb.ControllerState_CAN_ERROR_PASSIVE
	fspb.ControllerState_CAN_ERROR_WARNING

func (*Client) ReadStream

func (c *Client) ReadStream(timeout time.Duration) (*StreamData, error)

ReadStream reads the next stream data object from the buffer returns the meta data and the unmarshalled function specific stream data

func (*Client) SendFrames

func (c *Client) SendFrames(frames []*fspb.Frame) error

SendFrames sends a slice of frames to the CAN bus if the queue on the device is not large enough to contain all frames, send nothing and return temporarily unavailable error

func (*Client) StartStream

func (c *Client) StartStream(opts ...StreamConfigOption) error

StartStream starts the stream on this connection. Arguments may be one or more of the following functions:

  • WithFilter
  • WithFBStreamOption(functionblock.WithXXXX(...))

Options that are not specified take default values.

func (*Client) StopStream

func (c *Client) StopStream() error

StopStream stops the stream on this connection

func (*Client) UploadConfiguration

func (c *Client) UploadConfiguration(opts ...ConfigOption) error

UploadConfiguration configures the analogInTypeA function block Arguments may be one or more of the following functions:

  • WithBitRate
  • WithSamplePoint
  • WithSJW
  • WithListenOnly

Options that are not specified take default value (Bitrate 500000, SamplePoint 0.8, SJW 1, ListenOnly false)

type ConfigOption

type ConfigOption func(*fspb.ConfigurationSet)

ConfigOption is a type to pass options to UploadConfiguration()

func WithBitRate

func WithBitRate(bitRate uint32) ConfigOption

WithBitRate may be passed to UploadConfiguration.

bitRate defines the bit rate in bis/s

func WithListenOnly

func WithListenOnly(listenOnly bool) ConfigOption

WithListenOnly may be passed to UploadConfiguration.

if activated it is not possible to send frames to the bus (and no ACK is sent by the CAN controller)

func WithSJW

func WithSJW(sjw uint8) ConfigOption

WithSJW may be passed to UploadConfiguration.

Synchronization Jump Width

func WithSamplePoint

func WithSamplePoint(samplePoint float32) ConfigOption

WithSamplePoint may be passed to UploadConfiguration.

Sample Point from 0.0-1.0 - basis to calculate tseg1 and tseg2

type Configuration

type Configuration struct {
	BitRate     uint32
	SamplePoint float32
	SJW         uint8
	ListenOnly  bool
}

Configuration describes the current configuration of the canL2 function. Returned by DownloadConfiguration()

type StreamConfigOption

type StreamConfigOption func(*StreamConfiguration)

StreamConfigOption is a type to pass options to StartStream()

func WithFBStreamOption

func WithFBStreamOption(opt functionblock.StreamConfigOption) StreamConfigOption

WithFBStreamOption may be passed to StartStream.

opt is one of the functions that may be passed to functionblock.StartStream, e.g. WithBucketSamples()

func WithFilter

func WithFilter(acceptanceCode uint32, acceptanceMask uint32) StreamConfigOption

WithFilter may be passed to StartStream.

acceptanceCode and acceptanceMask define the filter

type StreamConfiguration

type StreamConfiguration struct {
	FBOptions []functionblock.StreamConfigOption
	// contains filtered or unexported fields
}

StreamConfiguration defines the configuration of a stream

type StreamData

type StreamData struct {
	functionblock.StreamDataMeta
	FSData *fspb.StreamData
}

StreamData contains the meta data of the stream and the unmarshalled function specific data

Jump to

Keyboard shortcuts

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