Table of Contents

Interface ICanChannel

Namespace
Suucha.Can.Core.Abstractions
Assembly
Suucha.Can.Core.dll

Represents a CAN communication channel

public interface ICanChannel : IDisposable
Inherited Members

Properties

ChannelIndex

Channel index (0-based)

int ChannelIndex { get; }

Property Value

int

Configuration

Channel configuration

ChannelConfig Configuration { get; }

Property Value

ChannelConfig

IsStarted

Whether the channel is currently started

bool IsStarted { get; }

Property Value

bool

Methods

ClearBuffer()

Clears the receive buffer

void ClearBuffer()

GetErrorInfo()

Reads channel error information

ChannelErrorInfo GetErrorInfo()

Returns

ChannelErrorInfo

Channel error information

GetReceiveCount()

Gets the number of frames in the receive buffer

uint GetReceiveCount()

Returns

uint

Number of available frames

Receive(int)

Receives available CAN frames (non-blocking)

CanFrame[] Receive(int maxCount = 100)

Parameters

maxCount int

Maximum number of frames to receive

Returns

CanFrame[]

Array of received frames

Reset()

Resets the channel

void Reset()

Send(CanFrame)

Sends a CAN frame

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

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

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

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)

void Start()

Stop()

Stops the channel

void Stop()

Events

ErrorOccurred

Event raised when a channel error occurs

event EventHandler<ChannelErrorEventArgs>? ErrorOccurred

Event Type

EventHandler<ChannelErrorEventArgs>

MessageReceived

Event raised when a CAN frame is received

event EventHandler<CanFrame>? MessageReceived

Event Type

EventHandler<CanFrame>