Oakrey.UDS
2.0.2
dotnet add package Oakrey.UDS --version 2.0.2
NuGet\Install-Package Oakrey.UDS -Version 2.0.2
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.UDS" Version="2.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.UDS" Version="2.0.2" />
<PackageReference Include="Oakrey.UDS" />
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.UDS --version 2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Oakrey.UDS, 2.0.2"
#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.UDS@2.0.2
#: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.UDS&version=2.0.2
#tool nuget:?package=Oakrey.UDS&version=2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Oakrey.UDS
Overview
Oakrey.UDS is a .NET 10 class library implementing the ISO 14229 (UDS) diagnostic protocol.
It runs over Oakrey.ISOTP as the transport layer and exposes a fully async, CancellationToken-aware API through the UnifiedDiagnosticServices class.
Responses are returned as UdsResponse value types and can be post-processed with a set of chainable extension methods.
Main Features
Implemented UDS services
| Service | SID | Method |
|---|---|---|
| Diagnostic Session Control | 0x10 | DiagnosticSessionControl |
| ECU Reset | 0x11 | EcuReset |
| Clear Diagnostic Trouble Codes | 0x14 | ClearDiagnosticTroubleCodes |
| Read Data By Identifier | 0x22 | ReadDataByIdentifier |
| Read DTC Information | 0x19 | ReportDiagnosticTroubleCodesByStatusMask / ReportNumberOfDiagnosticTroubleCodesByStatusMask |
| Write Data By Identifier | 0x2E | WriteDataByIdentifier |
| Security Access | 0x27 | (internal, via SecurityAccess service) |
Response extension pipeline (UdsExtensions)
ProcessDTCs()� deserialises the DTC payload intoList<DiagnosticTroubleCodes>.ToAscii()� decodes the response data as ASCII text.ToBytes()� returns raw response bytes.ToUInt(offset, length)� extracts an unsigned integer from the response data.
Enumerations
DiagnosticSessionControlType�Default (0x01),Programming (0x02),Extended (0x03),EOL (0x40),Development (0x4F).EcuResetType�HardReset (0x01),KeyOffOnReset (0x02).StatusOfDtc� bitmask flags for DTC availability and status filtering.
Extensibility
UdsServiceBaseis public and can be subclassed to implement additional UDS services.IRequestdefines the contract used byUnifiedDiagnosticServicesfor request dispatch.
Architecture
graph TD
ISOTP["Oakrey.ISOTP<br>(ISOTPProtocol)"]
UDS["UnifiedDiagnosticServices<br>(public API)"]
Base["UdsServiceBase<br>(abstract)"]
Services["DiagnosticSessionControl<br>EcuReset<br>ClearDtc<br>ReadDataByIdentifier<br>WriteDataByIdentifier<br>ReadDtcInformation<br>SecurityAccess"]
Response["UdsResponse<br>(value type)"]
Ext["UdsExtensions<br>(ProcessDTCs, ToAscii,<br>ToBytes, ToUInt)"]
ISOTP --> UDS
UDS --> Base
Base --> Services
UDS --> Response
Response --> Ext
Requirements
- .NET 10 or higher
Oakrey.ISOTP(project reference or matching NuGet package)
Installation
.NET CLI
dotnet add package Oakrey.UDS
Package Manager Console
Install-Package Oakrey.UDS
NuGet Package Manager
- Open Visual Studio.
- Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
- Search for
Oakrey.UDSand click Install.
Example Usage
Setup
// Create and configure an ISO-TP protocol instance
ISOTPProtocol isoTp = new ISOTPProtocol();
isoTp.AddService("ECM", rXAddress: 0x7E8, tXAddress: 0x7E0);
// Subscribe CanTX to your CAN bus send method
isoTp.CanTX.Subscribe(msg => canBus.Send(msg.Id, msg.Data));
// Feed received CAN frames into ISO-TP
canBus.OnMessageReceived += (id, data) => isoTp.CanRX(id, data);
UnifiedDiagnosticServices uds = new UnifiedDiagnosticServices(isoTp);
Switch diagnostic session
UdsResponse response = await uds.DiagnosticSessionControl(
"ECM",
DiagnosticSessionControlType.Extended,
CancellationToken.None);
Read data by identifier
string vin = await uds
.ReadDataByIdentifier("ECM", 0xF190, CancellationToken.None)
.ToAscii();
Write data by identifier
UdsResponse response = await uds.WriteDataByIdentifier(
"ECM",
dataIdentifier: 0x0100,
data: [0x01, 0x02, 0x03],
CancellationToken.None);
Read and process DTCs
List<DiagnosticTroubleCodes> dtcs = await uds
.ReportDiagnosticTroubleCodesByStatusMask("ECM", StatusOfDtc.TestFailed, CancellationToken.None)
.ProcessDTCs();
foreach (DiagnosticTroubleCodes dtc in dtcs)
{
Console.WriteLine($"DTC: 0x{dtc.Code:X6} Status: {dtc.Status}");
}
ECU reset
await uds.EcuReset("ECM", EcuResetType.HardReset, CancellationToken.None);
Extract an integer from a response
uint odometer = await uds
.ReadDataByIdentifier("ECM", 0xA100, CancellationToken.None)
.ToUInt(offset: 0, length: 3);
Development Notes
UnifiedDiagnosticServicesuses a singlependingRequestfield � only one request can be in-flight at a time per instance. Concurrent use requires separate instances.UdsServiceBasesilently ignoresResponsePending (0x78)responses and continues waiting, in compliance with the UDS spec.SecurityAccessperforms the seed/key exchange internally: it requests the seed, computes the key using theLoginproperty, and sends the key reply automatically.UdsException.ThrowIfOperationFailedis called by all extension methods � failed responses surface as exceptions in the continuation task.- Base timeout is 3000 ms; override
BaseTimeoutin aUdsServiceBasesubclass to change it for custom services.
Project Information
- Author: Oakrey
- License: MIT
- Repository: Azure DevOps
- Package URL: nuget.org/packages/Oakrey.UDS
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 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Oakrey.ISOTP (>= 2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.