CanIdFilter Struct¶
Allocation-free ID-range/mask filter for a ISubscription (FR-RAW-013, "Should"). This is the fast path for the common case "one 11/29-bit CAN-ID range (or acceptance code/mask) per protocol instance": it is evaluated directly against the read-only CanFrameView that the demux layer carries, without allocating or invoking a generic System.Func<> delegate per frame.
Remarks¶
The match logic (ID-type/extended guard + inclusive range / acceptance-mask compare)
intentionally mirrors CanKit.Core.Definitions.FilterRule.Range and
FilterRule.Mask so this package does not introduce a parallel filter vocabulary.
It is replicated here rather than reused because those rules compile to a
Func<CanFrame, bool> that operates on the disposable CanFrame,
whereas the demux layer only ever exposes the non-owning CanFrameView; the
range/mask check itself is a couple of integer comparisons, so replicating it is both
simpler and cheaper than converting a view back into a frame per match. The
CanFilterIDType vocabulary is reused as-is.
Properties¶
CanIdFilter.IdType Property¶
ID space this filter targets (standard 11-bit vs. extended 29-bit). Frames of the other ID space never match.
Property Value¶
Methods¶
CanIdFilter.Mask(uint, uint, CanFilterIDType) Method¶
Creates an acceptance-code/mask filter: a frame matches when
(id & accMask) == (accCode & accMask).
public static CanKit.Pro.RawCan.CanIdFilter Mask(uint accCode, uint accMask, CanKit.Abstractions.API.Common.Definitions.CanFilterIDType idType=CanKit.Abstractions.API.Common.Definitions.CanFilterIDType.Standard);
Parameters¶
accCode UInt32
Acceptance code.
accMask UInt32
Acceptance mask; only the set bits are compared.
idType CanFilterIDType
Standard or extended ID space.
Returns¶
Exceptions¶
ArgumentOutOfRangeException
The pair requires a bit outside idType's ID space to be set --
(accCode & accMask) reaches above 0x7FF (standard) or 0x1FFFFFFF (extended).
No real CAN ID has those bits set, so the filter could never match. A mask that reaches
above the ID space is fine on its own: it then merely requires those bits to be zero,
which every ID already satisfies.
CanIdFilter.Matches(CanFrameView) Method¶
Returns true when frame matches this filter.
Parameters¶
frame CanFrameView
Returns¶
CanIdFilter.Overlaps(CanIdFilter) Method¶
True if some CAN ID exists that both this filter and other would match (FR-RAW-041, "Should") -- a diagnostic for catching misconfigured protocol instances whose subscriptions were meant to have disjoint ID spaces. Filters targeting different IdType spaces (Standard vs. Extended) never overlap, since a frame is never both.
Parameters¶
other CanIdFilter
Returns¶
CanIdFilter.Range(uint, uint, CanFilterIDType) Method¶
Creates an inclusive ID-range filter [from..to].
public static CanKit.Pro.RawCan.CanIdFilter Range(uint from, uint to, CanKit.Abstractions.API.Common.Definitions.CanFilterIDType idType=CanKit.Abstractions.API.Common.Definitions.CanFilterIDType.Standard);
Parameters¶
from UInt32
Minimum ID, inclusive.
to UInt32
Maximum ID, inclusive.
idType CanFilterIDType
Standard or extended ID space.
Returns¶
Exceptions¶
ArgumentException
to is below from.
ArgumentOutOfRangeException
A bound lies outside idType's ID space (0x7FF for standard,
0x1FFFFFFF for extended). Such a filter can never match anything, because
Matches(CanFrameView) only ever sees IDs already clipped to that space — the usual
cause is a 29-bit ID passed without CanFilterIDType.Extend.