Oakrey.Guru.Base
5.0.0
dotnet add package Oakrey.Guru.Base --version 5.0.0
NuGet\Install-Package Oakrey.Guru.Base -Version 5.0.0
<PackageReference Include="Oakrey.Guru.Base" Version="5.0.0" />
<PackageVersion Include="Oakrey.Guru.Base" Version="5.0.0" />
<PackageReference Include="Oakrey.Guru.Base" />
paket add Oakrey.Guru.Base --version 5.0.0
#r "nuget: Oakrey.Guru.Base, 5.0.0"
#:package Oakrey.Guru.Base@5.0.0
#addin nuget:?package=Oakrey.Guru.Base&version=5.0.0
#tool nuget:?package=Oakrey.Guru.Base&version=5.0.0
Oakrey.Guru.Base
Base device library for Oakrey Guru USB hardware adapters. Provides the core abstractions and default implementations used by all Guru protocol adapters (CAN, LIN, and others).
Main features
IDevice- common contract for Guru adapters: connect, ping, firmware update, bootloader resetILicense- multi-slot license key retrieval (GetLicenseKey,GetAllLicenseKeys,GetBootLicense)DeviceBase- abstract base class that wires together anITransceiverand a handler pipeline; extend this to build a concrete adapterFirmwareUpdater- async firmware update from an Intel HEX file; handles bootloader entry, waits for the device to re-enumerate as a mass-storage drive, copies the file, and triggers rebootFirmwareUpdateException- specific exception type for firmware update failures, with a built-in file-existence guardDeviceExtensions.VerifyConnection- runs N ping round-trips, logs average latency, and throws on mismatchHardwareTimeStamp<T>- generic value type that pairs a hardware-reported timestamp with the hostDateTime
Architecture
classDiagram
class IDevice {
+Connect(ct)
+Ping(data, ct)
+GetFwVersion(ct)
+RestartToBootloader(ct)
+UpdateFirmware(path, ct)
+FwUpdateInProgress IObservable~bool~
}
class ILicense {
+GetLicenseKey(id, ct)
+GetAllLicenseKeys(ct)
+GetBootLicense(ct)
}
class DeviceBase {
#transceiver ITransceiver
#commandsManager HandlerCollection
#deviceLock SemaphoreSlim
}
IDevice <|.. DeviceBase
ILicense <|.. DeviceBase
DeviceBase <|-- ConcreteAdapter
DeviceBase subscribes to ITransceiver.Received and dispatches each incoming packet to the matching handler via HandlerCollection. Concrete adapters (e.g. CanGuruAdapter, LinGuruAdapter) inherit from DeviceBase, register their own handlers, and expose a protocol-specific API.
Key types
| Type | Purpose |
|---|---|
DeviceBase |
Abstract base; handles lifecycle, locking, and handler dispatch |
FirmwareUpdater |
Coordinates bootloader entry and HEX file delivery over mass storage |
DeviceExtensions |
Extension methods for connection verification with latency reporting |
HardwareTimeStamp<T> |
Pairs hardware and host timestamps |
FirmwareUpdateException |
Thrown on firmware update failures |
Requirements
- .NET 10 (Windows only �
System.Management/ WMI is used to detect the bootloader drive) - The Guru adapter must support the Guru packet protocol
Installation
.NET CLI
dotnet add package Oakrey.Guru.Base
Package Manager Console
Install-Package Oakrey.Guru.Base
NuGet Package Manager
Search for Oakrey.Guru.Base in Visual Studio under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Example usage
Connect and ping
// adapter is a concrete DeviceBase implementation supplied by e.g. Oakrey.Guru.Can
using MyGuruAdapter adapter = new(transceiver);
await adapter.Connect(cancellationToken);
uint echo = await adapter.Ping(0xDEADBEEF, cancellationToken);
Read firmware version and license keys
string version = await adapter.GetFwVersion(cancellationToken);
List<string> keys = await adapter.GetAllLicenseKeys(cancellationToken);
Firmware update
adapter.FwUpdateInProgress.Subscribe(inProgress =>
Console.WriteLine(inProgress ? "Update started" : "Update finished"));
await adapter.UpdateFirmware(@"C:\firmware\v2.hex", cancellationToken);
The updater:
- Sends the bootloader-entry command to the device.
- Waits (up to 5 s) for the device to re-enumerate as a removable drive using WMI
Win32_VolumeChangeEvent. - Copies the
.hexfile to that drive. - Writes a
reboottrigger file to complete the update.
Development notes
- All async methods accept a
CancellationTokenand propagate it through the call chain. deviceLock(aSemaphoreSlim(1,1)) serialises all handler executions; do not bypass it in subclasses.FwUpdateInProgressis aBehaviorSubject-backedIObservable<bool>; subscribe before callingUpdateFirmwareto observe the full lifecycle.System.Managementis consumed withPrivateAssets="All"so it is not exposed as a transitive dependency to consumers.
Project information
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| Target framework | net10.0-windows |
| NuGet package | Oakrey.Guru.Base |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/Drivers |
License
MIT. 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.Guru.Handlers (>= 5.0.0)
- Oakrey.Log.Abstractions (>= 3.0.0)
- System.Management (>= 10.0.9)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Oakrey.Guru.Base:
| Package | Downloads |
|---|---|
|
Oakrey.Guru.Lin
LIN bus adapter library for Oakrey Guru USB hardware. Provides up to 8 independent channels with master/slave role control, baud rate configuration (up to 19200), slave answer table management, bus voltage reading, and reactive Rx streams (ReceivedFrame, StatusChanged, ErrorEvent). |
|
|
Oakrey.Guru.Can
CAN and CAN-FD adapter library for Oakrey Guru USB hardware. Provides dual-channel bus configuration, per-channel timing and termination, message filtering, inter-channel bridge mode, reactive Rx streams (ReceivedMessage, ReceivedCanEvent, DriverStatusChanged), and simulation support via ISimGuru. |
|
|
Oakrey.Emu.Can
CAN emulator adapter library for Oakrey Guru Emu USB hardware. Exposes indexed simulation input writing (WriteInputValue) and CRC verification (GetSimCrc) for hardware-in-the-loop testing on top of Oakrey.Guru.Base. |
GitHub repositories
This package is not used by any popular GitHub repositories.