CanId class final

A CAN arbitration ID together with its format (11-bit or 29-bit).

Use it as a map key where standard and extended IDs with the same numeric value must stay apart, for example in per-ID statistics or a trace view.

final rpm = CanId.standard(0x7E8);
final j1939 = CanId.extended(0x18FEF100);
print(rpm.hex); // '7E8'
Implemented types
Annotations

Constructors

CanId(int value, {bool isExtended = false})
Creates an ID. Throws CanConfigException if value is out of range for the format.
CanId.extended(int value)
Creates a 29-bit ID.
factory
CanId.standard(int value)
Creates an 11-bit ID.
factory

Properties

hashCode → int
The hash code for this object.
no setteroverride
hex → String
Upper-case hex: 3 digits for standard IDs, 8 for extended IDs.
no setter
isExtended → bool
True for a 29-bit ID.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → int
Numeric ID value without flag bits.
final

Methods

compareTo(CanId other) → int
Orders standard IDs before extended ones, then by value.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

formatHex(int value, {required bool isExtended}) → String
Formats an ID like candump: 3 hex digits (standard) or 8 (extended).
validate(int value, {required bool isExtended}) → void
Throws CanConfigException if value is not a valid ID for the format.

Constants

maxExtended → const int
Largest 29-bit ID (0x1FFFFFFF).
maxStandard → const int
Largest 11-bit ID (0x7FF).