CanHub.Core
1.0.1
dotnet add package CanHub.Core --version 1.0.1
NuGet\Install-Package CanHub.Core -Version 1.0.1
<PackageReference Include="CanHub.Core" Version="1.0.1" />
<PackageVersion Include="CanHub.Core" Version="1.0.1" />
<PackageReference Include="CanHub.Core" />
paket add CanHub.Core --version 1.0.1
#r "nuget: CanHub.Core, 1.0.1"
#:package CanHub.Core@1.0.1
#addin nuget:?package=CanHub.Core&version=1.0.1
#tool nuget:?package=CanHub.Core&version=1.0.1
CanHub.Core
CanHub.Core provides the coordination layer for CanHub applications: DI registration, adapter lookup, endpoint parsing, scanning fan-out, frame broadcasting, and configuration conflict helpers. It depends on CanHub.Abstractions, but not on vendor SDKs.
Install
dotnet add package CanHub.Core
Add at least one adapter package, such as CanHub.Adapter.Virtual, CanHub.Adapter.Vector, or CanHub.Adapter.Zlg, before opening endpoints.
Register Adapters With DI
Use DI when the host application already has a service container. Console applications that create their own provider may also need to reference Microsoft.Extensions.DependencyInjection.
using CanHub;
using CanHub.Adapter.Virtual;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddCanHub()
.AddVirtualAdapter();
using var provider = services.BuildServiceProvider();
var registry = provider.GetRequiredService<CanHubRegistry>();
Adapters are registered explicitly. CanHub does not use reflection-based package auto-discovery.
For small tools and tests, a direct registry is also available:
using CanHub;
using CanHub.Adapter.Virtual;
var registry = CanHubRegistry.CreateDefault()
.AddVirtualAdapter();
Open A Bus
var endpoint = CanEndpoint.Create("virtual", "demo", channelIndex: 0);
await using var bus = await registry.OpenAsync(
endpoint,
new CanOpenOptions { BusParameters = CanBusParameters.Classic500k },
CancellationToken.None);
using var subscription = bus.Subscribe(new CanSubscriptionOptions());
Endpoint schemes are mapped to registered adapters. Unknown schemes fail before any vendor runtime is touched. Adapter packages may provide dedicated endpoint builders, such as ZlgEndpoint or VectorEndpoint, for fixed-device configuration.
Scan Devices
var scan = await registry.ScanAsync(new ScanOptions(), CancellationToken.None);
The registry asks every adapter that supports scanning and returns both discovered devices and diagnostics. Missing hardware or missing native drivers should be surfaced as diagnostics rather than crashing the host process. If a channel came from scanning, prefer registry.OpenAsync(channel, options, ct) or the scanned endpoint fields instead of rebuilding the endpoint manually.
Broadcast And Conflict Helpers
FrameBroadcastHub fans out frame events to subscriptions with bounded queues. Slow subscribers can be dropped according to subscription settings without blocking the adapter receive loop.
LeaseConflictDetector creates deterministic fingerprints for bus configuration so adapters can detect incompatible shared-channel requests.
License
This package is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- CanHub.Abstractions (>= 1.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on CanHub.Core:
| Package | Downloads |
|---|---|
|
CanHub.Adapter.Vector
Vector CAN adapter for CanHub — provides CAN/CAN FD access via Vector XL Driver API. |
|
|
CanHub.Adapter.Virtual
In-process virtual CAN/CAN FD adapter for CanHub tests, samples, and protocol development. |
|
|
CanHub.Adapter.Zlg
ZLG CAN adapter for CanHub — provides CAN/CAN FD access via zlgcan.dll. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 128 | 6/1/2026 |
| 1.0.0-preview.8 | 68 | 5/25/2026 |
| 1.0.0-preview.7 | 64 | 5/23/2026 |
| 1.0.0-preview.6 | 72 | 5/21/2026 |
| 1.0.0-preview.5 | 60 | 5/21/2026 |
| 1.0.0-preview.4 | 67 | 5/21/2026 |
| 1.0.0-preview.3 | 65 | 5/20/2026 |
| 1.0.0-preview.2 | 62 | 5/19/2026 |
| 1.0.0-preview.1 | 68 | 5/15/2026 |
DI registration, endpoint opening, lease coordination, and frame broadcast infrastructure.