Skip to content

UdsFunctionalClient Class

UDS over functional addressing (ISO 14229-1 §7.5.4): one request on the functional CAN identifier, every ECU in the response range may answer. Built on IsoTpFunctionalClient, which carries only Single Frames both ways; a request that needs more than one frame, or an ECU whose answer does, is not for this path (#57).

public sealed class UdsFunctionalClient : System.IDisposable

Inheritance Object → UdsFunctionalClient

Implements IDisposable

Remarks

The typical uses are the keep-alive to everyone (3E 80) and a session change or short read broadcast to a set of ECUs. A negative response is one ECU's and does not fault the call: it is returned beside the others as a UdsFunctionalResponse with IsNegative set.

Properties

UdsFunctionalClient.Channel Property

The underlying ISO-TP functional client.

public CanKit.Pro.IsoTp.IsoTpFunctionalClient Channel { get; }

Property Value

IsoTpFunctionalClient

Methods

UdsFunctionalClient.Create(IsoTpFunctionalClient, bool, Nullable<TimeSpan>, Nullable<TimeSpan>) Method

Wraps an open IsoTpFunctionalClient. With ownsClient, disposing this client disposes it. responseWindow is how long after a request an ECU may still answer it -- P2 -- and so how long the next call for the same service waits before it collects, whether the request was suppressed or its collection window simply ended sooner; responsePendingWindow is what an NRC 0x78 seen in that time extends it by -- P2*. The defaults are DefaultP2 and DefaultP2Star. A window is moved out by at most 100 such 0x78s -- the default of MaxResponsePendingCount -- so a peer that answers 0x78 for ever holds the next call for the service up for a bounded time (#354).

public static CanKit.Pro.Uds.UdsFunctionalClient Create(CanKit.Pro.IsoTp.IsoTpFunctionalClient client, bool ownsClient=false, System.Nullable<System.TimeSpan> responseWindow=null, System.Nullable<System.TimeSpan> responsePendingWindow=null);

Parameters

client IsoTpFunctionalClient

ownsClient Boolean

responseWindow Nullable<TimeSpan>

responsePendingWindow Nullable<TimeSpan>

Returns

UdsFunctionalClient

UdsFunctionalClient.DiagnosticSessionControlAsync(UdsSessionType, TimeSpan, CancellationToken) Method

DiagnosticSessionControl to everyone, collecting each ECU's answer within window. Bit 7 of the session type is not accepted, as on DiagnosticSessionControlAsync(byte, CancellationToken).

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<CanKit.Pro.Uds.UdsFunctionalResponse>> DiagnosticSessionControlAsync(CanKit.Pro.Uds.UdsSessionType session, System.TimeSpan window, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

session UdsSessionType

window TimeSpan

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<UdsFunctionalResponse>>

UdsFunctionalClient.Dispose() Method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose();

Implements Dispose()

UdsFunctionalClient.SendRawAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken) Method

Sends request on the functional identifier and collects every ECU's answer to <em>it</em> that arrives within window: a positive response to the request's service, or a negative response naming it. Other traffic on the response identifiers -- another tester's answers, a late answer to an earlier request -- is not attributed to this call where the response lets it be told apart: a positive response is matched on the request bytes it echoes (the sub-function, a DID, a routine identifier, a block counter, a mode of operation, a memory address and size), a periodic read on the identifier it carries data for. For a service whose positive response echoes nothing of the request -- ClearDiagnosticInformation (0x14), ReadMemoryByAddress (0x23), RequestDownload and RequestUpload (0x34, 0x35), RequestTransferExit (0x37), SecuredDataTransmission (0x84) -- the service identifier is the whole correlation, and another tester's answer to the same service inside the window is attributed to this call. A request with suppressPosRspMsgIndication set is sent and not collected for: an empty list comes back as soon as the frame is confirmed.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<CanKit.Pro.Uds.UdsFunctionalResponse>> SendRawAsync(System.ReadOnlyMemory<byte> request, System.TimeSpan window, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

request ReadOnlyMemory<Byte>

window TimeSpan

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<UdsFunctionalResponse>>

Remarks

An NRC 0x78 (requestCorrectlyReceived-ResponsePending) names the service and is returned as a negative response like any other: IsNegative is set although that ECU's final answer is still to come -- after the window, where only the listener that moves the next call's wait out hears it. A caller counting refusals leaves out the entries whose NegativeResponseCode is 0x78 (#354).

UdsFunctionalClient.TesterPresentAsync(bool, Nullable<TimeSpan>, CancellationToken) Method

TesterPresent to everyone (3E 80): the keep-alive that reaches every ECU with one frame. With the positive response suppressed, the default, nothing is collected and window is ignored; without it, every ECU answers, and a window to collect them in is required.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<CanKit.Pro.Uds.UdsFunctionalResponse>> TesterPresentAsync(bool suppressPositiveResponse=true, System.Nullable<System.TimeSpan> window=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

suppressPositiveResponse Boolean

window Nullable<TimeSpan>

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<UdsFunctionalResponse>>

Exceptions

ArgumentNullException
suppressPositiveResponse is false and no window was given.