Table of Contents

Class CanChannelModule

Namespace
Loehnert.Lisrt.Can.Vector
Assembly
Loehnert.Lisrt.Can.Vector.dll

Represents a module for a Vector CAN channel with VXL API. Warning: You cannot use the interfaces Loehnert.Lisrt.Communication.Can.ICanCommunication and ICanCommunication2 at the same time on one instance.

public class CanChannelModule : LisrtModule, ILisrtModule, IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged, ICanCommunication2, IHasServiceView
Inheritance
PropertyChangedBase
CanChannelModule
Implements
INotifyPropertyChangedEx
Inherited Members
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged

Constructors

CanChannelModule(string)

Initializes a new instance of the CanChannelModule class.

public CanChannelModule(string name)

Parameters

name string

CAN channel name.

Properties

BaudRate

Gets or sets the baud rate.

[Configuration(0, Unit = "Baud", Description = "15k to 1M Baud")]
public uint BaudRate { get; set; }

Property Value

uint

ChannelIndex

Gets or sets the device depending channel index.

[Configuration(0)]
public byte ChannelIndex { get; set; }

Property Value

byte

ChannelName

Gets the channel name. Available after Initialize() or SetChannel(ChannelInfo). To get the unique channel identification use DeviceSerial and ChannelIndex.

public string ChannelName { get; }

Property Value

string

DataReceivedAutoResetEvent

Gets the auto reset event for received data.

protected AutoResetEvent DataReceivedAutoResetEvent { get; }

Property Value

AutoResetEvent

DataTransmittedAutoResetEvent

Gets the auto reset event for successfully transmitted data.

protected AutoResetEvent DataTransmittedAutoResetEvent { get; }

Property Value

AutoResetEvent

DeviceSerial

Gets or sets the device serial.

[Configuration(0)]
public uint DeviceSerial { get; set; }

Property Value

uint

Icon

Gets a icon which is representative for the module.

public override Uri Icon { get; }

Property Value

Uri

InitializationState

Gets a value indicating whether the module is initialized.

public InitializationState InitializationState { get; }

Property Value

InitializationState

ReceiveTimeoutInMS

Gets or sets the receive timeout in milliseconds. Default is 200ms.

public int ReceiveTimeoutInMS { get; set; }

Property Value

int

ReceivedBuffer

Gets the latest received data. Cleared on ClearBuffer(), Receive(), Send(CanData) and Query(CanData).

protected IList<CanData> ReceivedBuffer { get; }

Property Value

IList<CanData>

Methods

ClearBuffer()

Clears the received data buffer.

protected void ClearBuffer()

Exit()

De initializes the module.

public void Exit()

GetPossibleCanChannels()

Gets all possible CAN channels.

public IEnumerable<ChannelInfo> GetPossibleCanChannels()

Returns

IEnumerable<ChannelInfo>

All CAN channels.

Initialize()

Initializes the module.

public void Initialize()

Exceptions

InvalidOperationException

Thrown when channel is not found.

ArgumentException

Thrown when BaudRate is not between 15k to 1M baud.

Query(CanData)

Sends and receives data.

public IEnumerable<CanData> Query(CanData data)

Parameters

data CanData

Data to send.

Returns

IEnumerable<CanData>

Received data.

Exceptions

InvalidOperationException

Thrown when DataReceived has any event handler.

TimeoutException

Thrown when no data received in the expected time range.

ArgumentNullException

Thrown when data is null.

InvalidOperationException

Thrown when InitializationState is not Initialized.

TimeoutException

Thrown when no bus device acknowledged the transmission in the expected time range or not data is received in the expected time range.

Receive()

Receives the data from the buffer. The buffer is cleared on ClearBuffer(), Receive(), Send(CanData) and Query(CanData).

public IEnumerable<CanData> Receive()

Returns

IEnumerable<CanData>

Received data.

Exceptions

InvalidOperationException

Thrown when InitializationState is not Initialized.

InvalidOperationException

Thrown when DataReceived has any event handler.

Send(CanData)

Sends CanData to a device.

public void Send(CanData data)

Parameters

data CanData

Data to send.

Exceptions

ArgumentNullException

Thrown when data is null.

InvalidOperationException

Thrown when InitializationState is not Initialized.

TimeoutException

Thrown when no bus device acknowledged the transmission in the expected time range.

SetChannel(ChannelInfo)

Sets the channel with the channelInfo.

public void SetChannel(ChannelInfo channelInfo)

Parameters

channelInfo ChannelInfo

Channel info to set.

Exceptions

InvalidOperationException

Thrown when InitializationState is Initialized.

ShowServiceView()

Shows the service window.

public void ShowServiceView()

Events

DataReceived

Occurs when data are received.

public event EventHandler DataReceived

Event Type

EventHandler