J1939TpOptions Class¶
Configuration for a IJ1939TpChannel: J1939-21 §5.10 timing parameters, transmit priority, and per-channel bounds. All values are captured at channel construction time and treated as immutable for its lifetime.
Inheritance Object → J1939TpOptions
Remarks¶
The J1939-21 §5.10.2.4 recommended values are hard-coded defaults; production callers can override any subset via With(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<byte>, Nullable<byte>, Nullable<int>, Nullable<int>, Nullable<int>, Nullable<bool>). Every timer defaults to its standard value: - T1 = 750 ms — TP.DT gap timeout at the receiver. - T2 = 1250 ms — CTS→first TP.DT timeout at the receiver. - T3 = 1250 ms — RTS→CTS, block→next CTS and last DT→EndOfMsgAck timeout at the originator. - T4 = 1050 ms — TP.CM hold timeout at the originator after CTS(0) (§5.10.2.4).
The standard's Tr (200 ms) is the time a node has to <em>send</em> a response it owes, not a timer a peer is held to; this stack answers at once and has no option for it (#31). Its Th (500 ms) is the holding time between two CTS(0) messages a responder sends; this stack sends none and has no option for it either (#144). BamPacketSpacing (50 ms) is the spacing between two BAM packets, §5.10.3's 50..200 ms -- not a timer of §5.10.2.4.
Properties¶
J1939TpOptions.BamPacketSpacing Property¶
Minimum spacing between two consecutive BAM TP.DT frames on the wire (§5.10.3 "50..200 ms"). Default 50 ms to stay at the lower recommended bound while still gating against a receiver that cannot keep up. Not the standard's Th, which is the holding time between CTS(0) messages and which this stack does not use; this option was named Th before #144.
Property Value¶
J1939TpOptions.MaxPacketsPerCts Property¶
Maximum number of TP.DT packets per CTS this channel advertises when it is the receiver of a TP.CM session. Must be in [1, 255] (0 is illegal: a CTS with numPackets=0 is the "hold connection open" form, not a real grant). Defaults to 16, well below the 255 hard cap so a slow consumer can keep the block short.
Property Value¶
J1939TpOptions.MaxQueuedSendsPerDestination Property¶
How many sends may wait for their destination's session slot, per destination address, behind the one on the wire; a send the channel has accepted but not yet started counts as waiting, so the bound holds against a producer that outruns the channel. A send that would exceed it faults at the call, before its PDU is queued anywhere, with J1939TpSendRejectedException; every BAM goes to the global address, so this also bounds the BAMs waiting on the channel. Each waiting send holds its whole PDU (up to 1785 bytes) and, against a peer that never answers, drains at T3 pace, so an unbounded queue grows in memory and latency with the producer (#204). Default 8; 0 admits no waiting send at all. There is no overall queue deadline: the caller's CancellationToken bounds the wait, and a cancelled send leaves the queue at once.
Property Value¶
J1939TpOptions.MaxRetransmitRequests Property¶
How many times per TP.CM session this originator serves a CTS that asks for a packet it has already sent -- a retransmit request (§5.10.2.4); the next one is answered with Connection Abort reason 5, "maximum retransmit request limit reached" (table 7). The standard names the limit and leaves its value to the implementation. Default 2; 0 serves none (#58).
Property Value¶
J1939TpOptions.Priority Property¶
TX priority for TP.CM / TP.DT frames sent by this channel (0..7, 0 = highest). J1939-21 uses 7 by default for its transport traffic.
Property Value¶
J1939TpOptions.ReceiveBufferCapacity Property¶
Bounded capacity of the internal receive buffer that holds fully reassembled PDUs waiting for the consumer. Drops the oldest PDU when full so the RX pipeline never stalls the actor. Defaults to 32.
Property Value¶
J1939TpOptions.SendConnectionAbortRole Property¶
Whether a TP.CM Connection Abort this channel sends carries its Connection Abort Role: the role this node has in the session it aborts, in bits 2..1 of byte 3 (J1939-21, second edition: 00 = originator, the node that sent the RTS; 01 = responder, the node the RTS was sent to), with the other six bits of the byte left at 1. A peer that runs a TP.CM transfer of the same PGN in both directions with this node needs it to tell which of the two one abort ends. Default false: byte 3 stays 0xFF, the first edition's reserved value, which is also what the Linux kernel's j1939 stack sends -- a strict or first-edition peer may refuse an abort whose reserved byte is not 0xFF and then keep its session until its own timeout. Turn it on for a network whose peers implement the second edition. Receiving does not depend on it: an abort's role is read when present and only decides between two sessions its PGN matches, and 0xFF reads as no role (#350).
Property Value¶
J1939TpOptions.T1 Property¶
T1 — TP.DT gap timeout at the receiver (J1939-21 §5.10.2.4). Default 750 ms.
Property Value¶
J1939TpOptions.T2 Property¶
T2 — the receiver's timeout from its CTS to the first TP.DT of the granted block (§5.10.2.4). Default 1250 ms. Before #31 this window was held to Tr (200 ms), which rejected a conforming but slow originator.
Property Value¶
J1939TpOptions.T3 Property¶
T3 — the originator's timeout for the response it is owed: CTS after RTS, the next CTS after the last TP.DT of a block, EndOfMsgAck after the last TP.DT (§5.10.2.4). Default 1250 ms.
Property Value¶
J1939TpOptions.T4 Property¶
T4 — originator-side hold timeout after a CTS with numPackets=0 ("hold connection open"). Per J1939-21 §5.10.2.4, lack of a follow-up CTS within T4 closes the connection. Default 1050 ms.
Property Value¶
Methods¶
J1939TpOptions.With(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<byte>, Nullable<byte>, Nullable<int>, Nullable<int>, Nullable<int>) Method¶
Returns a copy of these options with the provided overrides. The 1.3.0 signature, kept so that callers compiled against it still bind; source callers resolve to the overload with every parameter optional. SendConnectionAbortRole is kept.
public CanKit.Pro.J1939Tp.J1939TpOptions With(System.Nullable<System.TimeSpan> t1, System.Nullable<System.TimeSpan> t2, System.Nullable<System.TimeSpan> t3, System.Nullable<System.TimeSpan> t4, System.Nullable<System.TimeSpan> bamPacketSpacing, System.Nullable<byte> priority, System.Nullable<byte> maxPacketsPerCts, System.Nullable<int> receiveBufferCapacity, System.Nullable<int> maxRetransmitRequests, System.Nullable<int> maxQueuedSendsPerDestination);
Parameters¶
bamPacketSpacing Nullable<TimeSpan>
maxPacketsPerCts Nullable<Byte>
receiveBufferCapacity Nullable<Int32>
maxRetransmitRequests Nullable<Int32>
maxQueuedSendsPerDestination Nullable<Int32>
Returns¶
J1939TpOptions.With(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<byte>, Nullable<byte>, Nullable<int>, Nullable<int>, Nullable<int>, Nullable<bool>) Method¶
Convenience clone that returns a new instance with the provided overrides; a null argument keeps this instance's value. Useful for deriving a per-channel configuration from a shared template, SendConnectionAbortRole included.
public CanKit.Pro.J1939Tp.J1939TpOptions With(System.Nullable<System.TimeSpan> t1=null, System.Nullable<System.TimeSpan> t2=null, System.Nullable<System.TimeSpan> t3=null, System.Nullable<System.TimeSpan> t4=null, System.Nullable<System.TimeSpan> bamPacketSpacing=null, System.Nullable<byte> priority=null, System.Nullable<byte> maxPacketsPerCts=null, System.Nullable<int> receiveBufferCapacity=null, System.Nullable<int> maxRetransmitRequests=null, System.Nullable<int> maxQueuedSendsPerDestination=null, System.Nullable<bool> sendConnectionAbortRole=null);
Parameters¶
bamPacketSpacing Nullable<TimeSpan>
maxPacketsPerCts Nullable<Byte>
receiveBufferCapacity Nullable<Int32>
maxRetransmitRequests Nullable<Int32>
maxQueuedSendsPerDestination Nullable<Int32>
sendConnectionAbortRole Nullable<Boolean>
Returns¶
Exceptions¶
ArgumentOutOfRangeException
Thrown when maxPacketsPerCts is 0, or maxRetransmitRequests
or maxQueuedSendsPerDestination is negative.