ICanSharp 0.0.2

dotnet add package ICanSharp --version 0.0.2
                    
NuGet\Install-Package ICanSharp -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ICanSharp" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ICanSharp" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ICanSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ICanSharp --version 0.0.2
                    
#r "nuget: ICanSharp, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ICanSharp@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ICanSharp&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ICanSharp&version=0.0.2
                    
Install as a Cake Tool

ICanSharp

NuGet

CAN bus communication library for .NET 8.0 and .NET 10.0 using the observer pattern.

Features

  • Observer pattern for CAN frame distribution
  • Flexible frame filtering with mask-based filtering
  • Async/await support
  • Thread-safe observer management
  • Multi-targeting (.NET 8.0 & .NET 10.0)

Installation

dotnet add package ICanSharp

Quick Start

1. Create a CAN Port Implementation

using CanSharp;

public class MyCanPort : CanPortBase
{
    public MyCanPort(int cardId, int portId)
    {
        PortGuid = new CanGuid(0, 0, cardId, portId);
        Description = $"My CAN Port {cardId}/{portId}";
    }

    public override void Send(CanFrame frame)
    {
        // Implement your hardware-specific send logic
    }

    // Call this when receiving data from hardware
    private void OnDataReceived(int canId, byte[] data, bool isExtended)
    {
        var frame = new CanFrame(canId, data, isExtended);
        ProcessReceive(frame);
    }
}

2. Register Port and Add Observer

var port = new MyCanPort(0, 0);
CanPortManager.Instance.AddPort(port);

var observer = new CanObserver
{
    CanFilter = CanFilter.ById(0x123, 0x7FF)
};
observer.OnReceive += (p, frame) =>
{
    Console.WriteLine($"Received: ID={frame.CanId:X}, Len={frame.Length}");
};

port.AddObserver(observer);
port.Open();

3. Send CAN Frames

var frame = new CanFrame(0x123, new byte[] { 0x01, 0x02, 0x03 });
port.Send(frame);
await port.SendAsync(frame);

Filtering

// Accept all
observer.CanFilter = CanFilter.AcceptAll();

// By ID
observer.CanFilter = CanFilter.ById(0x123);

// Standard frames only
observer.CanFilter = new CanFilter { ExframeFilterFlag = ExframeFilterFlag.Can20A };

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 108 3/9/2026
0.0.1 103 3/5/2026