Table of Contents

Class ZlgCanChannel

Namespace
Suucha.Can.Zlg.Devices
Assembly
Suucha.Can.Zlg.Devices.dll

Represents a ZLG CAN channel (supports all ZLG device types)

public class ZlgCanChannel : ICanChannel, IDisposable
Inheritance
ZlgCanChannel
Implements
Inherited Members

Properties

ChannelIndex

Channel index (0-based)

public int ChannelIndex { get; }

Property Value

int

Configuration

Channel configuration

public ChannelConfig Configuration { get; }

Property Value

ChannelConfig

IsStarted

Whether the channel is currently started

public bool IsStarted { get; }

Property Value

bool

Methods

ClearBuffer()

Clears the receive buffer

public void ClearBuffer()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~ZlgCanChannel()

Finalizer to ensure proper cleanup of native resources.

protected ~ZlgCanChannel()

GetErrorInfo()

Reads channel error information

public ChannelErrorInfo GetErrorInfo()

Returns

ChannelErrorInfo

Channel error information

GetReceiveCount()

Gets the number of frames in the receive buffer

public uint GetReceiveCount()

Returns

uint

Number of available frames

Receive(int)

Receives available CAN frames (non-blocking)

public CanFrame[] Receive(int maxCount = 100)

Parameters

maxCount int

Maximum number of frames to receive

Returns

CanFrame[]

Array of received frames

Reset()

Resets the channel

public void Reset()

Send(CanFrame)

Sends a CAN frame

public int Send(CanFrame frame)

Parameters

frame CanFrame

Frame to send

Returns

int

Number of frames sent (1 on success, 0 on failure)

Exceptions

TransmitException

Thrown when transmission fails

SendAsync(CanFrame, CancellationToken)

Sends a CAN frame asynchronously

public Task<int> SendAsync(CanFrame frame, CancellationToken cancellationToken = default)

Parameters

frame CanFrame

Frame to send

cancellationToken CancellationToken

Cancellation token

Returns

Task<int>

Number of frames sent

SendBatch(IEnumerable<CanFrame>)

Sends multiple CAN frames

public int SendBatch(IEnumerable<CanFrame> frames)

Parameters

frames IEnumerable<CanFrame>

Frames to send

Returns

int

Number of frames successfully sent

Exceptions

TransmitException

Thrown when transmission fails

SendBatchAsync(IEnumerable<CanFrame>, CancellationToken)

Sends multiple CAN frames asynchronously

public Task<int> SendBatchAsync(IEnumerable<CanFrame> frames, CancellationToken cancellationToken = default)

Parameters

frames IEnumerable<CanFrame>

Frames to send

cancellationToken CancellationToken

Cancellation token

Returns

Task<int>

Number of frames successfully sent

Start()

Starts the channel (begins receiving frames)

public void Start()

Stop()

Stops the channel

public void Stop()

Events

ErrorOccurred

Event raised when a channel error occurs

public event EventHandler<ChannelErrorEventArgs>? ErrorOccurred

Event Type

EventHandler<ChannelErrorEventArgs>

MessageReceived

Event raised when a CAN frame is received

public event EventHandler<CanFrame>? MessageReceived

Event Type

EventHandler<CanFrame>