ISO22900.II-Sharp 0.0.2-beta

This is a prerelease version of ISO22900.II-Sharp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ISO22900.II-Sharp --version 0.0.2-beta                
NuGet\Install-Package ISO22900.II-Sharp -Version 0.0.2-beta                
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="ISO22900.II-Sharp" Version="0.0.2-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ISO22900.II-Sharp --version 0.0.2-beta                
#r "nuget: ISO22900.II-Sharp, 0.0.2-beta"                
#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.
// Install ISO22900.II-Sharp as a Cake Addin
#addin nuget:?package=ISO22900.II-Sharp&version=0.0.2-beta&prerelease

// Install ISO22900.II-Sharp as a Cake Tool
#tool nuget:?package=ISO22900.II-Sharp&version=0.0.2-beta&prerelease                

ISO22900.II-Sharp

ISO22900.II-Sharp handles all the details of operating with unmanaged ISO 22900-2 spec library (also called D-PDU-API) and lets you deal with the important stuff.

The ISO 22900-2 friendly name is D-PDU-API both are synonymous for a software interface description. D-PDU-API can live alone but was normally designed in use with ISO 22900-X and ISO 22901-X in mind. All this spec libraries has the goal to make automotive diagnostic data interchangeable. In case of ISO 22900-2 this correctly means modular vehicle communication interface (MVCI or VCI) can be exchanged through MVCI from another manufacturer if both support ISO 22900-2.

Extract from 22900-2: "The purpose of ISO 22900-2 is to ensure that diagnostic and reprogramming applications from any vehicle or tool manufacturer can operate on a common software interface and can easily exchange MVCI protocol module implementations."

Usage

using System;
using System.Collections.Generic;
using System.Linq;
using ISO22900.II;

namespace ISO22900.II.Example
{
public class Program
{
public static async Task Main(string[] args)
{
    //The helper functions read registry and root xml
    var allInstalledPduApis = DiagPduApiHelper.InstalledMvciPduApiDetails().ToList();
    if ( allInstalledPduApis.Any() )
    {
        //take the first API
        var apiShortName = allInstalledPduApis.First().ShortName;
        using ( var api = DiagPduApiOneFactory.GetApi(DiagPduApiHelper
                   .FullyQualifiedLibraryFileNameFormShortName(apiShortName)) )
        {
            //without parameters means the first VCI that is found
            using ( var vci = api.ConnectVci() )
            {
                //Define the protocol behavior
                //These names (the strings) come from ODX or ISO 22900-2
                var dlcPinData = new Dictionary<uint, string> { { 6, "HI" }, { 14, "LOW" } };
                var busTypeName = "ISO_11898_2_DWCAN";
                var protocolName = "ISO_15765_3_on_ISO_15765_2";

                using ( var link = vci.OpenComLogicalLink(busTypeName, protocolName, dlcPinData.ToList()) )
                {
                    //Set UniqueId ComParam's
                    uint pageOneId = 815; //give page one a ID  
                    link.SetUniqueRespIdTablePageOneUniqueRespIdentifier(pageOneId);
                    link.SetUniqueIdComParamValue(pageOneId, "CP_CanPhysReqId", 0x7E0);
                    link.SetUniqueIdComParamValue(pageOneId, "CP_CanRespUSDTId", 0x7E8);

                    //Set normal ComParam's
                    link.SetComParamValueViaGet("CP_P2Max", 500000);

                    link.Connect();

                    var request = new byte[] { 0x22, 0xF1, 0x90 };

                    using ( var cop = link.StartCop(PduCopt.PDU_COPT_SENDRECV, 1, 1, request) )
                    {
                        var result = await cop.WaitForCopResultAsync();

                        var responseString = string.Empty;
                        uint responseTime = 0;
                        if ( result.DataMsgQueue().Count > 0 )
                        {
                            responseString = string.Join(",", 
                                result.DataMsgQueue().ConvertAll(bytes => { return BitConverter.ToString(bytes); }));
                            responseTime = result.ResponseTime();
                        }
                        else if ( result.PduEventItemErrors().Count > 0 )
                        {
                            foreach ( var error in result.PduEventItemErrors() )
                            {
                                responseString += $"{error.ErrorCodeId}" + $" ({error.ExtraErrorInfoId})";
                            }

                            responseString = "Error: " + responseString;
                        }
                        Console.WriteLine($"{BitConverter.ToString(request)} | {responseString}  | {responseTime}µs");
                    }
                    link.Disconnect();
                }
            }
        }
    }
    Console.ReadKey();
}
}
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.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
1.1.2-beta 292 2/14/2023
1.1.1-beta 90 2/13/2023
1.1.0-beta 105 11/26/2022
1.0.1-beta 169 10/1/2022
1.0.0-beta 110 9/11/2022
0.0.2-beta 161 3/11/2022
0.0.1-beta 133 2/5/2022

beta (works and will be expanded with additional functions soon)