![]() |
VOOZH | about |
dotnet add package Oakrey.Guru.Can --version 4.0.5
NuGet\Install-Package Oakrey.Guru.Can -Version 4.0.5
<PackageReference Include="Oakrey.Guru.Can" Version="4.0.5" />
<PackageVersion Include="Oakrey.Guru.Can" Version="4.0.5" />Directory.Packages.props
<PackageReference Include="Oakrey.Guru.Can" />Project file
paket add Oakrey.Guru.Can --version 4.0.5
#r "nuget: Oakrey.Guru.Can, 4.0.5"
#:package Oakrey.Guru.Can@4.0.5
#addin nuget:?package=Oakrey.Guru.Can&version=4.0.5Install as a Cake Addin
#tool nuget:?package=Oakrey.Guru.Can&version=4.0.5Install as a Cake Tool
CAN and CAN-FD adapter library for Oakrey Guru USB hardware. Provides dual-channel bus configuration, per-channel filtering, bridge mode, reactive Rx streams, and simulation support on top of Oakrey.Guru.Base.
Channel.CAN0 and Channel.CAN1 controlled independentlyConfig and CanTimingSamplePoint, TQCount, SyncJumpWidth), reset, reloadIdFilter, RangeFilter, DualFilter; global filter policy via GlobalFilterBridgeMode (NONE / ALLOW / DENY); append specific IDs to a bridge listIObservable<ReceivedMessage>, IObservable<ReceivedCanEvent>, IObservable<DriverStatusChanged>ISimGuru exposes WriteInputValue and GetSimCrc for hardware-in-the-loop scenariosIGuruLicense with per-slot and boot license accessDeviceBase: firmware update, ping, bootloader reset, FwUpdateInProgress observableclassDiagram
class IDevice {
+Connect(ct)
+Ping(data, ct)
+GetFwVersion(ct)
+UpdateFirmware(path, ct)
+RestartToBootloader(ct)
+FwUpdateInProgress IObservable~bool~
}
class ICanGuru {
+ReceivedMessage IObservable~ReceivedMessage~
+ReceivedCanEvent IObservable~ReceivedCanEvent~
+CanDrvStatusChanged IObservable~DriverStatusChanged~
+Enable(channel, enable, ct)
+ConfigSet(channel, config, ct)
+FilterSet(channel, type, index, filter, ct)
+GlobalFilterSet(channel, globalFilter, ct)
+CanTimingSet(channel, canTiming, ct)
+SetBridgeMode(mode, ct)
+ClearBridgeMode(list, ct)
+AppendBridgeMode(list, ids, ct)
+Send(channel, message)
}
class ISimGuru {
+WriteInputValue(index, value, ct)
+GetSimCrc(ct)
}
class IGuruLicense {
+GetLicenseKey(id, ct)
+GetAllLicenseKeys(ct)
+GetBootLicense(ct)
}
class CanGuruAdapter {
+Create(serial, quid, ct)$ Task~CanGuruAdapter~
}
IDevice <|.. CanGuruAdapter
ICanGuru <|.. CanGuruAdapter
ISimGuru <|.. CanGuruAdapter
IGuruLicense <|.. CanGuruAdapter
| Type | Description |
|---|---|
Config |
CAN/CAN-FD bus config: baud rates, FD enable, monitor-only |
CanTiming |
Nominal and data-phase timing: sample point, TQ count, SJW |
Message |
TX/RX message: identifier, FD flags, BRS, ESI, RTR, data |
ReceivedMessage |
Received message with hardware timestamp |
ReceivedCanEvent |
CAN event (e.g. bus error) with timestamp |
DriverStatusChanged |
Driver state transition notification |
BridgeMode |
Enum: NONE / ALLOW / DENY |
BridgeList |
Identifies a bridge pair (CAN0-CAN1) |
Channel |
Enum: CAN0 / CAN1 |
IdFilter / RangeFilter / DualFilter |
Concrete filter implementations |
Oakrey.Guru.Base (transitive).NET CLI
dotnet add package Oakrey.Guru.Can
Package Manager Console
Install-Package Oakrey.Guru.Can
NuGet Package Manager
Search for Oakrey.Guru.Can in Visual Studio under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
// serial: device serial number, quid: USB device qualifier GUID
CanGuruAdapter adapter = await CanGuruAdapter.Create(serial, quid, cancellationToken);
Config config = new()
{
ArbitrationBaudRate = 500_000,
FdDataPhaseBaudRate = 2_000_000,
FdEnable = true,
MonitorOnly = false,
};
await adapter.ConfigSet(Channel.CAN0, config, cancellationToken);
await adapter.TerminatorEnable(Channel.CAN0, true, cancellationToken);
await adapter.Enable(Channel.CAN0, true, cancellationToken);
CanTiming timing = new(
nominal: new Timing(samplePoint: 750, tQCount: 16, syncJumpWidth: 1),
data: new Timing(samplePoint: 750, tQCount: 8, syncJumpWidth: 1));
await adapter.CanTimingSet(Channel.CAN0, timing, cancellationToken);
Message message = new()
{
Identifier = 0x1A0,
FDEnabled = true,
BitRateSwitchEnabled = true,
Data = [0x01, 0x02, 0x03, 0x04],
};
adapter.Send(Channel.CAN0, message);
using IDisposable subscription = adapter.ReceivedMessage
.Subscribe(msg => Console.WriteLine($"ID: {msg.Message.Identifier:X} Data: {BitConverter.ToString(msg.Message.Data)}"));
// Allow only IDs 0x100 to 0x1FF on CAN0 standard filters, slot 0
await adapter.FilterSet(Channel.CAN0, FilterType.Standard, 0, new RangeFilter(0x100, 0x1FF), cancellationToken);
await adapter.Reload(Channel.CAN0, cancellationToken);
// Forward all traffic from CAN0 to CAN1
await adapter.SetBridgeMode(BridgeMode.ALLOW, cancellationToken);
// Forward only specific IDs
await adapter.AppendBridgeMode(BridgeList.CAN0_CAN1, [0x1A0, 0x1B0], cancellationToken);
adapter.FwUpdateInProgress.Subscribe(active =>
Console.WriteLine(active ? "Firmware update in progress..." : "Firmware update complete."));
await adapter.UpdateFirmware(@"C:\firmware\can_guru_v4.hex", cancellationToken);
CanGuruAdapter is sealed; use the ICanGuru / ISimGuru / IGuruLicense interfaces in consuming code.Reload to take effect; Reset clears all channel state.ReceivedMessage, ReceivedCanEvent, and CanDrvStatusChanged are hot observables backed by Subject; subscribe before enabling the channel to avoid missing early events.CancellationToken and propagate it through the handler pipeline.Send is fire-and-forget (synchronous enqueue); use the Rx subscription to observe results.| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| Target framework | net10.0-windows |
| NuGet package | Oakrey.Guru.Can |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/Drivers |
MIT. See the LICENSE file for details.
Run the following command in your Package Manager Console:
Install-Package Oakrey.Guru.Can
Contributions are welcome! Feel free to open issues or submit pull requests to improve the package.
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 net10.0-windows7.0 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.