Skip to content

LssBitRateDetectionOptions Class

How DetectAsync(Func<int,ICanBus>, LssBitRateDetectionOptions, CancellationToken) walks the bit-rate table.

public sealed class LssBitRateDetectionOptions

Inheritance Object → LssBitRateDetectionOptions

Properties

LssBitRateDetectionOptions.Candidates Property

The bit rates to try, in this order. Defaults to DefaultCandidates. Each must be positive and appear once.

public System.Collections.Generic.IReadOnlyList<int> Candidates { get; init; }

Property Value

IReadOnlyList<Int32>

LssBitRateDetectionOptions.DefaultCandidates Property

The CiA 301 bit rates (CiA 801 Table 1), with 500, 250 and 125 kbit/s first: most networks use one of the three, so trying them first finds the rate in fewer frames (CiA 801 §6). The rest follow in table order.

public static System.Collections.Generic.IReadOnlyList<int> DefaultCandidates { get; }

Property Value

IReadOnlyList<Int32>

LssBitRateDetectionOptions.DefaultListenWindow Property

The listen window per candidate when none is chosen: 2 seconds.

public static System.TimeSpan DefaultListenWindow { get; }

Property Value

TimeSpan

LssBitRateDetectionOptions.ErrorFramesToReject Property

How many error frames at one candidate rule it out. Defaults to 2, the CiA 801 §5.2.3 improvement over Figure 1: a single corrupted frame at the correct rate (§7) then does not move the search on. At a wrong rate every frame on the bus is an error, so the second one follows at once. Must be at least 1.

public int ErrorFramesToReject { get; init; }

Property Value

Int32

LssBitRateDetectionOptions.ListenWindow Property

How long to listen at one candidate before moving on when neither a frame nor enough errors arrive. Defaults to DefaultListenWindow. The traffic on the bus decides what is long enough: a heartbeat producer at 1 s needs a window above 1 s.

public System.TimeSpan ListenWindow { get; init; }

Property Value

TimeSpan

LssBitRateDetectionOptions.Passes Property

How many times to walk Candidates before giving up without a result. Defaults to 1. Must be at least 1. Figure 1 starts over at the end of the table; a bus that is silent at the moment the correct rate is tried needs the second pass.

public int Passes { get; init; }

Property Value

Int32

LssBitRateDetectionOptions.RequireListenOnly Property

When true (the default), a bus the factory opens in a work mode other than ListenOnly fails the detection. CiA 801 §5.2.1 requires the search not to disturb the network: a controller in normal mode at a wrong rate transmits error frames. Turn this off only on a bench where that is acceptable, or for an adapter that is silent in normal mode and does not report the listen-only mode.

public bool RequireListenOnly { get; init; }

Property Value

Boolean

Remarks

The check reads the work mode the bus reports, which is the mode the factory asked for; whether the controller is actually silent is the adapter's doing. A bus of an adapter known to report listen-only without applying it fails as well — on CanKit 0.5.6 that is the Kvaser adapter, which never sets the silent output mode (#345). For such an adapter CiA 801 §5.2.4 prescribes external hardware that holds the transmit line recessive; with it, turning this off makes the search non-reactive again.