Oakrey.Applications.Ohm.CAN
3.0.0
dotnet add package Oakrey.Applications.Ohm.CAN --version 3.0.0
NuGet\Install-Package Oakrey.Applications.Ohm.CAN -Version 3.0.0
<PackageReference Include="Oakrey.Applications.Ohm.CAN" Version="3.0.0" />
<PackageVersion Include="Oakrey.Applications.Ohm.CAN" Version="3.0.0" />
<PackageReference Include="Oakrey.Applications.Ohm.CAN" />
paket add Oakrey.Applications.Ohm.CAN --version 3.0.0
#r "nuget: Oakrey.Applications.Ohm.CAN, 3.0.0"
#:package Oakrey.Applications.Ohm.CAN@3.0.0
#addin nuget:?package=Oakrey.Applications.Ohm.CAN&version=3.0.0
#tool nuget:?package=Oakrey.Applications.Ohm.CAN&version=3.0.0
Oakrey.Applications.Ohm.CAN
A robust .NET service layer for discovering, configuring, connecting, receiving from, and transmitting through Oakrey CAN hardware devices.
The package builds on Oakrey.Applications.Ohm and adapts Oakrey.HardwareManager.Client.CAN to common channel, device, and service abstractions.
Features
- Discovery and management of multiple CAN devices
- Enabled-channel connection through
ICanDeviceService.Connect IObservable<CanReceivedData>streams at channel, device, and service levelIObservable<DeviceStatus>lifecycle streams- Per-channel transmission through
ICanChannel.Transmit - Serialized channel connection and device refresh operations
- Safe ownership and disposal of CAN clients and Rx subscriptions
- Persistent channel aliases, enabled state, and trace selection
- Debounced USB hot-plug discovery
- Cancellation support for asynchronous operations
Installation
dotnet add package Oakrey.Applications.Ohm.CAN
The library targets .NET 11 for Windows and requires the Oakrey Hardware Manager service supported by Oakrey.HardwareManager.Client.CAN.
Main types
| Type | Purpose |
|---|---|
ICanDeviceService / CanDeviceService |
Application-level entry point for discovery, configuration, and aggregate streams |
ICanDevice / CanDevice |
A physical CAN adapter and its channels |
ICanChannel / CanChannel |
One CAN channel, its receive stream, and transmit operation |
CanDeviceConfig |
Serializable device configuration |
CanChannelConfig |
Serializable channel configuration |
CanChannelCollection |
Observable CAN channel collection |
CanChannel, CanDevice, and CanDeviceService derive from the lifecycle implementations in Oakrey.Applications.Ohm. CAN-specific classes supply hardware-client creation, device discovery, and transmit support.
Dependency injection
Register the service as a singleton so its clients and subscriptions are disposed at application shutdown:
services.AddSingleton<ICanDeviceService, CanDeviceService>();
The constructor dependencies are:
IApplicationInfofor locating the configuration directoryIJsonServicefor configuration persistenceIFileServicefor configuration-file operationsIUsbNotifyingServicefor automatic device discovery
Basic usage
await canDeviceService.RefreshAvailableDevices(cancellationToken);
await canDeviceService.LoadDevicesConfig(cancellationToken);
await canDeviceService.Connect(cancellationToken);
using IDisposable subscription = canDeviceService.Received.Subscribe(data =>
{
// Decode or route the received CAN data.
});
Resolve a channel and transmit an existing message:
ICanChannel channel = canDeviceService.GetDevice(serialNumber, channelNumber);
CanMessage message = CreateMessage();
await channel.Transmit(message, cancellationToken);
Transmit rejects a disconnected or disposed channel with InvalidOperationException or ObjectDisposedException respectively.
Configuration
Configuration is stored in userDevicesCan.json beside IApplicationInfo.UserSettingsPath. It includes the device identity and each channel's number, alias, enabled state, and trace state.
Only enabled channels are connected. Configure them before calling Connect:
foreach (ICanChannel channel in canDeviceService.Devices.SelectMany(device => device.Channels))
{
channel.Enabled = true;
}
await canDeviceService.Connect(cancellationToken);
Save configuration explicitly when needed:
canDeviceService.SaveDevicesConfig();
If the application clean-config keyboard combination is held during service construction, the saved CAN configuration is removed.
Status, errors, and cancellation
using IDisposable statusSubscription = canDeviceService.Status.Subscribe(status =>
{
// Unknown, Connected, Disconnected, or Error.
});
- Invalid serial numbers or channel numbers passed to
GetDeviceproduceKeyNotFoundException. - A channel or device configuration for another target is rejected with
ArgumentException. - Cancellation is propagated as
OperationCanceledException. - Connection, transmission, receive-stream, and discovery failures are logged; lifecycle failures publish
DeviceStatus.Errorwhere applicable. - Calls that require a live service or channel reject use after disposal.
USB hot-plug behavior
USB notifications are debounced for two seconds. A newer notification cancels the pending refresh, preventing overlapping discovery runs during a burst of arrival/removal events. After a successful automatic refresh, the current configuration is saved.
Preloading and shutdown
CanDeviceService implements IPreLoadable. Preloading discovers devices, waits briefly for hardware stabilization, and then applies saved configuration. Failures are published through the IPreLoadable observable.
The service implements IDisposable. Disposal cancels pending USB refreshes, saves configuration, disconnects devices, disposes subscriptions and clients, and completes its observable streams.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0-windows7.0 is compatible. |
-
net11.0-windows7.0
- Oakrey.Applications.Ohm.Abstractions (>= 3.0.0)
- Oakrey.HardwareManager.Client.CAN (>= 5.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Oakrey.Applications.Ohm.CAN:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.DecodingServices.CAN
DBC-based CAN frame decoding service for .NET applications. Connects CAN device reception with loaded DBC definitions and exposes decoded messages, signal samples, unknown frames, message history, and reactive decoder statistics. |
|
|
Oakrey.Applications.CANDecodingServices
DBC-based CAN frame decoding service for .NET applications. Connects CAN device reception with loaded DBC definitions and exposes decoded messages, signal samples, unknown frames, message history, and reactive decoder statistics. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 51 | 11/15/2026 |
| 2.0.2 | 161 | 9/21/2026 |
| 2.0.1 | 142 | 9/4/2026 |
| 2.0.0 | 142 | 9/4/2026 |
| 1.0.0 | 134 | 9/3/2026 |
| 0.8.0-beta | 133 | 9/3/2026 |
| 0.7.1-beta | 117 | 8/6/2026 |
| 0.7.0-beta | 134 | 7/20/2026 |
| 0.6.2-beta | 121 | 7/8/2026 |
| 0.6.1-beta | 118 | 7/3/2026 |
| 0.6.0-beta | 127 | 5/22/2026 |
| 0.3.4-beta | 118 | 5/22/2026 |
| 0.3.3-beta | 120 | 5/15/2026 |
| 0.3.2-beta | 136 | 3/13/2026 |
| 0.3.1-beta | 125 | 2/11/2026 |
| 0.3.0-beta | 451 | 11/18/2025 |
| 0.2.1-beta | 230 | 9/29/2025 |
| 0.2.0-beta | 238 | 9/24/2025 |
| 0.1.0-beta | 213 | 8/15/2025 |