Oakrey.Guru.Lin
6.0.0
dotnet add package Oakrey.Guru.Lin --version 6.0.0
NuGet\Install-Package Oakrey.Guru.Lin -Version 6.0.0
<PackageReference Include="Oakrey.Guru.Lin" Version="6.0.0" />
<PackageVersion Include="Oakrey.Guru.Lin" Version="6.0.0" />
<PackageReference Include="Oakrey.Guru.Lin" />
paket add Oakrey.Guru.Lin --version 6.0.0
#r "nuget: Oakrey.Guru.Lin, 6.0.0"
#:package Oakrey.Guru.Lin@6.0.0
#addin nuget:?package=Oakrey.Guru.Lin&version=6.0.0
#tool nuget:?package=Oakrey.Guru.Lin&version=6.0.0
Oakrey.Guru.Lin
LIN bus adapter library for Oakrey Guru USB hardware. Provides multi-channel LIN communication with master and slave roles, frame scheduling, slave answer table management, and reactive Rx streams on top of Oakrey.Guru.Base.
Main features
- Up to 8 independent LIN channels (
Channel.Ch0�Ch7), each independently configured and enabled - Four operating modes per channel:
Observe,SlaveAnswer,MasterUser,MasterAuto - Baud rate configuration up to 19200 baud with enhanced or classic checksum selection
- Master frame scheduling: add
MasterFramewith configurable inter-frame delay; send one-shotMasterRequest - Slave answer table: register, update, and remove per-ID
SlaveAnswerentries - Bus voltage reading (
ReadLinVoltage) and per-channel status byte (ReadStatus) - Reactive Rx streams:
IObservable<ReceivedFrame>,IObservable<StatusChanged>,IObservable<ErrorEvent> - Inherits from
DeviceBase: firmware update from Intel HEX, ping, bootloader reset,FwUpdateInProgressobservable
Architecture
classDiagram
class IDevice {
+Connect(ct)
+Ping(data, ct)
+GetFwVersion(ct)
+UpdateFirmware(path, ct)
+RestartToBootloader(ct)
+FwUpdateInProgress IObservable~bool~
}
class ILinGuru {
+Received IObservable~ReceivedFrame~
+StatusChanged IObservable~StatusChanged~
+Error IObservable~ErrorEvent~
+WriteConfig(channel, config, ct)
+WriteEnable(channel, enable, ct)
+MasterEnable(channel, enable, ct)
+AddMasterFrame(channel, frame, ct)
+AddMasterRequest(channel, request, ct)
+ClearMaster(channel, ct)
+SendFrame(channel, frame, ct)
+SendRequest(channel, request, ct)
+UpdateSlaveAnswer(channel, answer, ct)
+RemoveSlaveAnswer(channel, id, ct)
+ClearSlaveAnswer(channel, ct)
+ReadLinVoltage(ct)
+ReadStatus(channel, ct)
+Reset(channel, ct)
}
class LinGuruAdapter {
+Create(serial, quid, ct)$ Task~LinGuruAdapter~
}
IDevice <|.. LinGuruAdapter
ILinGuru <|.. LinGuruAdapter
Key data types
| Type | Description |
|---|---|
Config |
Channel config: baud rate (max 19200) and Mode |
Mode |
Enum: Observe / SlaveAnswer / MasterUser / MasterAuto |
Channel |
Enum: Ch0 � Ch7 |
MasterFrame |
TX frame: ID, checksum type, data, inter-frame delay (ms) |
MasterRequest |
One-shot TX request (no scheduled delay) |
SlaveAnswer |
Slave response entry: ID, checksum type, data |
ReceivedFrame |
Received frame with hardware timestamp |
StatusChanged |
Channel status transition event |
ErrorEvent |
LIN bus error event |
LinGuruHalException |
Thrown on HAL-level violations (e.g. baud rate exceeded) |
Requirements
- .NET 11 (Windows only)
Oakrey.Guru.Base(transitive)- Oakrey Guru LIN USB hardware adapter
Installation
.NET CLI
dotnet add package Oakrey.Guru.Lin
Package Manager Console
Install-Package Oakrey.Guru.Lin
NuGet Package Manager
Search for Oakrey.Guru.Lin in Visual Studio under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Example usage
Create and connect
// serial: device serial number, quid: USB device qualifier GUID
LinGuruAdapter adapter = await LinGuruAdapter.Create(serial, quid, cancellationToken);
Configure and enable a channel
Config config = new(baudRate: 19200, mode: Mode.MasterAuto);
await adapter.WriteConfig(Channel.Ch0, config, cancellationToken);
await adapter.WriteEnable(Channel.Ch0, true, cancellationToken);
await adapter.MasterEnable(Channel.Ch0, true, cancellationToken);
Schedule a master frame
// ID 0x20, enhanced checksum, 4 bytes data, 10 ms inter-frame delay
MasterFrame frame = new(id: 0x20, enhancedCheckSum: true, data: [0x01, 0x02, 0x03, 0x04], delayMillis: 10);
await adapter.AddMasterFrame(Channel.Ch0, frame, cancellationToken);
Register a slave answer
SlaveAnswer answer = new(id: 0x30, enhancedCheckSum: true, data: [0xAA, 0xBB]);
await adapter.UpdateSlaveAnswer(Channel.Ch0, answer, cancellationToken);
Receive frames reactively
using IDisposable subscription = adapter.Received
.Subscribe(rx => Console.WriteLine($"ID: {rx.Frame.Id:X2} Data: {BitConverter.ToString(rx.Frame.Data)}"));
Read bus voltage
uint millivolts = await adapter.ReadLinVoltage(cancellationToken);
Console.WriteLine($"LIN bus voltage: {millivolts} mV");
Firmware update
adapter.FwUpdateInProgress.Subscribe(active =>
Console.WriteLine(active ? "Firmware update in progress..." : "Firmware update complete."));
await adapter.UpdateFirmware(@"C:\firmware\lin_guru_v4.hex", cancellationToken);
Development notes
LinGuruAdapterissealed; use theILinGuruinterface in consuming code.Received,StatusChanged, andErrorare hot observables; subscribe before enabling the channel to avoid missing early events.- All async methods accept a
CancellationTokenand propagate it through the handler pipeline. MasterFramedelay is enforced by the hardware scheduler;MasterRequestis a single unconditional transmission.ClearMasterremoves all scheduled master frames;ClearSlaveAnswerclears the entire slave answer table for the channel.Configconstructor throwsLinGuruHalExceptionifbaudRateexceeds 19200.
Project information
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| Target framework | net11.0-windows |
| NuGet package | Oakrey.Guru.Lin |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/Drivers |
License
MIT. See the LICENSE file for details.
- Company: Oakrey
- License: MIT
- Repository: Git Repository
- Project URL: Project Website
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve the package.
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 | net11.0-windows7.0 is compatible. |
-
net11.0-windows7.0
- Oakrey.Guru.Base (>= 6.0.0)
- Oakrey.Log.Abstractions (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.