Oakrey.Applications.Ohm.CAN
0.6.0-beta
dotnet add package Oakrey.Applications.Ohm.CAN --version 0.6.0-beta
NuGet\Install-Package Oakrey.Applications.Ohm.CAN -Version 0.6.0-beta
<PackageReference Include="Oakrey.Applications.Ohm.CAN" Version="0.6.0-beta" />
<PackageVersion Include="Oakrey.Applications.Ohm.CAN" Version="0.6.0-beta" />
<PackageReference Include="Oakrey.Applications.Ohm.CAN" />
paket add Oakrey.Applications.Ohm.CAN --version 0.6.0-beta
#r "nuget: Oakrey.Applications.Ohm.CAN, 0.6.0-beta"
#:package Oakrey.Applications.Ohm.CAN@0.6.0-beta
#addin nuget:?package=Oakrey.Applications.Ohm.CAN&version=0.6.0-beta&prerelease
#tool nuget:?package=Oakrey.Applications.Ohm.CAN&version=0.6.0-beta&prerelease
Oakrey.Applications.Ohm.CAN
A .NET library that provides a service layer for managing CAN bus hardware devices and channels.
It wraps Oakrey.HardwareManager.Client.CAN with a higher-level abstraction that covers
device discovery, connection lifecycle, reactive data streams, configuration persistence,
and USB hot-plug support.
Main features
- Enumerate and manage multiple CAN devices and their channels via
ICanDeviceService - Reactive
IObservable<CanReceivedData>stream for received CAN frames - Reactive
IObservable<DeviceStatus>stream for connection state changes - Per-channel transmit support via
ICanChannel.Transmit - Persistent user configuration saved as JSON (
userDevicesCan.json) - USB hot-plug detection through
IUsbNotifyingService - Configurable channel aliases, enabled/disabled state, and trace selection
- Clean-config keyboard shortcut at startup
Architecture
classDiagram
class ICanDeviceService {
+AsyncObservableCollection~ICanDevice~ Devices
+IObservable~CanReceivedData~ Received
+IObservable~DeviceStatus~ Status
+Connect(CancellationToken)
+Disconnect()
+RefreshAvailableDevices(CancellationToken)
+SaveDevicesConfig()
+LoadDevicesConfig()
}
class ICanDevice {
+string SerialNumber
+CanChannelCollection Channels
+IObservable~CanReceivedData~ Received
+IObservable~DeviceStatus~ Status
+ConnectAllChannels(CancellationToken)
+DisconnectAllChannels()
}
class ICanChannel {
+int ChannelNumber
+bool Enabled
+bool Traced
+IObservable~CanReceivedData~ Received
+Connect(CancellationToken)
+Disconnect()
+Transmit(CanMessage, CancellationToken)
}
ICanDeviceService "1" --> "*" ICanDevice
ICanDevice "1" --> "*" ICanChannel
Key types
| Type | Description |
|---|---|
ICanDeviceService / CanDeviceService |
Top-level service; entry point for consumers |
ICanDevice / CanDevice |
Represents a physical CAN adapter |
ICanChannel / CanChannel |
Represents one channel on a device |
CanDeviceConfig |
Serializable configuration snapshot for a device |
CanChannelConfig |
Serializable configuration snapshot for a channel |
DeviceStatus |
Enum: Unknown, Connected, Disconnected, Error |
Requirements
- .NET 10 or higher
Oakrey.HardwareManager.Client.CAN4.0.0Oakrey.HardwareManager.Client.Common4.0.0Oakrey.ViewModels2.1.0Oakrey.Log2.0.0
Installation
.NET CLI
dotnet add package Oakrey.Applications.Ohm.CAN
Package Manager Console
Install-Package Oakrey.Applications.Ohm.CAN
NuGet Package Manager
Search for Oakrey.Applications.Ohm.CAN in Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Configuration
User device settings are automatically saved to and loaded from:
<UserSettingsPath>\userDevicesCan.json
UserSettingsPath is provided via IApplicationInfo at construction time.
To reset the configuration, hold the clean-config keyboard combination while starting the application.
The combination is resolved by KeyboardExtension.IsCleanConfigCombinationPressed().
Example usage
Register the service with your DI container:
services.AddSingleton<ICanDeviceService, CanDeviceService>();
Discover devices and connect:
await canDeviceService.RefreshAvailableDevices(cancellationToken);
await canDeviceService.Connect(cancellationToken);
Subscribe to received CAN frames:
canDeviceService.Received.Subscribe(data =>
{
Console.WriteLine($"Frame received on {data.ChannelName}");
});
Transmit a CAN message on a specific channel:
ICanChannel channel = canDeviceService.GetDevice(serialNumber, channelNumber);
await channel.Transmit(new CanMessage { /* ... */ }, cancellationToken);
Save and load device configuration:
canDeviceService.SaveDevicesConfig();
canDeviceService.LoadDevicesConfig();
Development notes
CanDeviceServiceimplementsIPreLoadable, allowing it to participate in application pre-load sequences.- All async methods accept a
CancellationTokenand must not be blocked with.Wait()or.Result. CanDeviceServiceisIDisposable; ensure it is disposed when the application shuts down to release hardware resources and Rx subscriptions.
Project information
- Author: Oakrey
- License: MIT
- Repository: ApplicationServices
- Package URL: NuGet - Oakrey.Applications.Ohm.CAN
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Oakrey.Applications.Abstractions (>= 6.0.0)
- Oakrey.Applications.Files.Abstractions (>= 6.0.0)
- Oakrey.Applications.Json.Abstractions (>= 6.0.0)
- Oakrey.Applications.UsbNotifying (>= 2.0.5)
- Oakrey.HardwareManager.Client.CAN (>= 4.0.0)
- Oakrey.HardwareManager.Client.Common (>= 4.0.0)
- Oakrey.Log (>= 2.0.1)
- Oakrey.ViewModels (>= 2.1.0)
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.6.0-beta | 59 | 5/22/2026 |
| 0.3.4-beta | 57 | 5/22/2026 |
| 0.3.3-beta | 60 | 5/15/2026 |
| 0.3.2-beta | 81 | 3/13/2026 |
| 0.3.1-beta | 66 | 2/11/2026 |
| 0.3.0-beta | 397 | 11/18/2025 |
| 0.2.1-beta | 174 | 9/29/2025 |
| 0.2.0-beta | 183 | 9/24/2025 |
| 0.1.0-beta | 159 | 8/15/2025 |