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" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.UDS" />
                    
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.UDS --version 2.0.2
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.UDS&version=2.0.2
                    
Install as a Cake Tool

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 into List<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

  • DiagnosticSessionControlTypeDefault (0x01), Programming (0x02), Extended (0x03), EOL (0x40), Development (0x4F).
  • EcuResetTypeHardReset (0x01), KeyOffOnReset (0x02).
  • StatusOfDtc � bitmask flags for DTC availability and status filtering.

Extensibility

  • UdsServiceBase is public and can be subclassed to implement additional UDS services.
  • IRequest defines the contract used by UnifiedDiagnosticServices for 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

  1. Open Visual Studio.
  2. Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  3. Search for Oakrey.UDS and 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

  • UnifiedDiagnosticServices uses a single pendingRequest field � only one request can be in-flight at a time per instance. Concurrent use requires separate instances.
  • UdsServiceBase silently ignores ResponsePending (0x78) responses and continues waiting, in compliance with the UDS spec.
  • SecurityAccess performs the seed/key exchange internally: it requests the seed, computes the key using the Login property, and sends the key reply automatically.
  • UdsException.ThrowIfOperationFailed is called by all extension methods � failed responses surface as exceptions in the continuation task.
  • Base timeout is 3000 ms; override BaseTimeout in a UdsServiceBase subclass to change it for custom services.

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 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.

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
2.0.2 103 5/22/2026
2.0.1 102 5/15/2026
2.0.0 194 2/2/2026
1.0.0 360 4/22/2025