IsoTpFunctionalClient Class¶
ISO-TP functional (1:N broadcast) client per ISO 15765-2 §9 / ISO 14229-1 §7.5.4.
Inheritance Object → IsoTpFunctionalClient
Implements IDisposable
Remarks¶
Functional addressing allows a tester to broadcast a Single-Frame request on a shared functional CAN identifier and collect Single-Frame responses from multiple ECUs, each replying on its own physical response CAN identifier.
Send restriction: ISO 15765-2 §9.4 requires that functional requests are Single Frames only. Attempting to send a PDU that exceeds the Single-Frame capacity for the configured frame kind faults the returned task with InvalidOperationException. This is intentional: the standard prohibits multi-frame functional requests because there is no dedicated physical address to which each ECU could send a Flow-Control frame.
Response collection:SendAndCollectAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken) and CollectResponsesAsync(TimeSpan, CancellationToken) collect Single-Frame responses that arrive within a caller-supplied time window. First-Frame responses are not reassembled (they would require the tester to know each ECU's physical response-to-request addressing, which is not available in the general functional-addressing case); they are silently dropped. Flow-Control and Consecutive-Frame messages are likewise dropped.
Threading:SendAndCollectAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken), SendAsync(ReadOnlyMemory<byte>, CancellationToken), and CollectResponsesAsync(TimeSpan, CancellationToken) are safe to call from any thread. They are not mutually concurrent — only one call at a time is meaningful because each creates a fresh subscription window; callers that need to serialise multiple rounds should await each call in turn. Dispose is thread-safe and idempotent.
Properties¶
IsoTpFunctionalClient.FunctionalTxCanId Property¶
The functional TX CAN identifier used for outbound Single Frames.
Property Value¶
IsoTpFunctionalClient.Options Property¶
The options this client was opened with.
Property Value¶
Methods¶
IsoTpFunctionalClient.CollectResponsesAsync(TimeSpan, CancellationToken) Method¶
Creates a fresh response subscription and collects Single-Frame responses from any ECU whose response CAN-ID falls within the configured range for the duration of window.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<CanKit.Pro.IsoTp.IsoTpFunctionalResponse>> CollectResponsesAsync(System.TimeSpan window, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
window TimeSpan
Duration to collect responses.
cancellationToken CancellationToken
Cancels the collection window early.
Returns¶
Task<IReadOnlyList<IsoTpFunctionalResponse>>
All Single-Frame responses received within the window, in arrival order.
Remarks¶
When called after SendAsync(ReadOnlyMemory<byte>, CancellationToken), there is a small window between send and subscribe where a very fast ECU response may be missed. Use SendAndCollectAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken) to eliminate that race.
IsoTpFunctionalClient.SendAndCollectAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken) Method¶
Sends pdu as a Single Frame on the functional CAN identifier, then collects Single-Frame responses from any ECU whose response CAN-ID falls within the configured range, returning all responses received within window.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<CanKit.Pro.IsoTp.IsoTpFunctionalResponse>> SendAndCollectAsync(System.ReadOnlyMemory<byte> pdu, System.TimeSpan window, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
User-data payload. Must fit in one ISO-TP Single Frame (≤ 7 bytes for classic CAN without address extension, ≤ 62 bytes for CAN-FD). Violating this limit faults the task with InvalidOperationException — multi-frame functional requests are prohibited by ISO 15765-2 §9.4.
window TimeSpan
Duration to wait for responses after the Single Frame is TX-confirmed. Expired windows return all responses collected so far; they do not fault the task.
cancellationToken CancellationToken
Cancels both the TX-confirm wait and the response-collection window.
Returns¶
Task<IReadOnlyList<IsoTpFunctionalResponse>>
All Single-Frame responses received within the window, in arrival order.
May be empty if no ECU responded.
Exceptions¶
InvalidOperationException
pdu exceeds the Single-Frame capacity for the configured frame kind.
IsoTpException
The TX-confirm failed (bus-off, driver rejection, or N_As timeout).
IsoTpFunctionalClient.SendAsync(ReadOnlyMemory<byte>, CancellationToken) Method¶
Sends pdu as a Single Frame on the functional CAN identifier. The returned task completes when the CAN driver confirms the frame was accepted.
public System.Threading.Tasks.Task SendAsync(System.ReadOnlyMemory<byte> pdu, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
User-data payload. Must fit in a Single Frame (see class remarks).
cancellationToken CancellationToken
Cancels the TX-confirm wait.
Returns¶
Exceptions¶
InvalidOperationException
pdu exceeds the Single-Frame capacity.
IsoTpException
TX-confirm failed.
Remarks¶
Prefer SendAndCollectAsync(ReadOnlyMemory<byte>, TimeSpan, CancellationToken) for the typical request/collect pattern, as it subscribes to the response range before sending so that no fast ECU response is missed.