Oakrey.Applications.Ohm.CAN 0.6.0-beta

This is a prerelease version of Oakrey.Applications.Ohm.CAN.
dotnet add package Oakrey.Applications.Ohm.CAN --version 0.6.0-beta
                    
NuGet\Install-Package Oakrey.Applications.Ohm.CAN -Version 0.6.0-beta
                    
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="Oakrey.Applications.Ohm.CAN" Version="0.6.0-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Ohm.CAN" Version="0.6.0-beta" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Ohm.CAN" />
                    
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 Oakrey.Applications.Ohm.CAN --version 0.6.0-beta
                    
#r "nuget: Oakrey.Applications.Ohm.CAN, 0.6.0-beta"
                    
#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 Oakrey.Applications.Ohm.CAN@0.6.0-beta
                    
#: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=Oakrey.Applications.Ohm.CAN&version=0.6.0-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Ohm.CAN&version=0.6.0-beta&prerelease
                    
Install as a Cake Tool

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.CAN 4.0.0
  • Oakrey.HardwareManager.Client.Common 4.0.0
  • Oakrey.ViewModels 2.1.0
  • Oakrey.Log 2.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

  • CanDeviceService implements IPreLoadable, allowing it to participate in application pre-load sequences.
  • All async methods accept a CancellationToken and must not be blocked with .Wait() or .Result.
  • CanDeviceService is IDisposable; ensure it is disposed when the application shuts down to release hardware resources and Rx subscriptions.

Project information

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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