Table of Contents

Class CanChannelModule

Namespace
Loehnert.Lisrt.Can.VSCom
Assembly
Loehnert.Lisrt.Can.VSCom.dll

Represents a module for a channel of a VSCOM CAN adapter with VS CAN API. USB and Ethernet adapters are supported.

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

Remarks

The installation of the VSCOM driver is necessary.

Important

You cannot use the ICanCommunication and the ICanCommunication2 API of an instance at the same time.

Network CAN Adapter

Using a network CAN adapter, you have to configure the Driver Mode, the configuration is done via the web interface of the adapter. The Connection property has to be configured in this format: IP-address:port, the port is 2001 by default.

USB CAN Adapter

The Connection property must be the COM-port name. In order to achieve the maximum performance, the Latency Timer of the FTDI chip should be set to the smallest value. You adapt the Latency Timer via the Windows Device Manager -> Right click on the COM port -> Properties -> Port Settings -> Advanced.

Constructors

CanChannelModule(string)

Initializes a new instance of the CanChannelModule class.

public CanChannelModule(string name)

Parameters

name string

Module name.

Properties

BaudRate

Gets or sets the baud rate.

[Configuration(0, Unit = "Baud", Description = "20000, 50000, 100000, 125000, 250000 500000, 800000 or 1000000 Baud")]
public uint BaudRate { get; set; }

Property Value

uint

CommunicationLogIsEnabled

Gets or sets a value indicating whether the instance logs communication.

[Configuration(true)]
public bool CommunicationLogIsEnabled { get; set; }

Property Value

bool

Connection

Gets or sets the connection name of the device. This could be a serial number, COM port or network address with port.

[Configuration("", Description = "Serial number, serial port or network address (Example: 192.168.100.51:2001).")]
public string Connection { get; set; }

Property Value

string

DeviceLabel

Gets or sets the label for the device.

[Configuration("")]
public string DeviceLabel { get; set; }

Property Value

string

InitializationState

Gets the initialization state.

public InitializationState InitializationState { get; }

Property Value

InitializationState

InstanceID

Gets or sets the ID for this instance.

public int InstanceID { get; set; }

Property Value

int

ReceiveTimeoutInMS

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

public int ReceiveTimeoutInMS { get; set; }

Property Value

int

Methods

Exit()

De initializes the module.

public void Exit()

Initialize()

Initializes the module.

public void Initialize()

Exceptions

ArgumentNullException

Thrown when Connection is null, empty or white space.

InvalidOperationException

Thrown when the connection to the device is already open.

ArgumentException

Thrown when BaudRate is not 20k, 50k, 100k, 125k, 250k 500k, 800k or 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 are received in the expected time range. See ReceiveTimeoutInMS.

ArgumentNullException

Thrown when parameter data is null.

NotInitializedException

Thrown when InitializationState is not Initialized.

Receive()

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

public IEnumerable<CanData> Receive()

Returns

IEnumerable<CanData>

Received data.

Exceptions

NotInitializedException

Thrown when InitializationState is not Initialized.

InvalidOperationException

Thrown when DataReceived has any event handler.

Send(CanData)

Sends CanData.

public void Send(CanData data)

Parameters

data CanData

Data to send.

Exceptions

ArgumentNullException

Thrown when data is null.

NotInitializedException

Thrown when InitializationState is not Initialized.

ShowServiceView()

Shows the service window.

public void ShowServiceView()

Events

DataReceived

Occurs when data are received.

public event EventHandler DataReceived

Event Type

EventHandler