can_bus_toolkit library
CAN bus toolkit for Flutter on Android: USB OTG transport, logging, statistics, ISO-TP, OBD-II, UDS and DBC decoding.
Import this library to get every module, or import a single module
(core.dart, usb.dart, obd.dart, dbc.dart) to keep the surface small.
Classes
- BackgroundLoggingStatus
- State of background logging.
- CanAdapterCapabilities
- What a USB CAN adapter supports.
- CanBus
- A connection to a CAN bus.
- CanBusLoad
- Bus-load estimation from frame bit lengths.
- CanBusStatistics
- Traffic statistics for one measurement window, plus running totals.
- CanBusStatus
- A bus state plus optional error counters and a reason.
- CanConfig
- Bus configuration used when opening a CanBitrate-based bus.
- CandumpLogReader
-
Reads
candump -Llogs. - CandumpLogWriter
-
Writes frames in
candump -Lformat:(seconds.micros) iface ID#DATA. - CandumpRecord
-
One line of a
candump -Llog. - CanErrorCounters
- Transmit and receive error counters (TEC/REC) reported by the controller.
- CanFilter
-
Acceptance filter: a frame passes when
(frame.id & mask) == (id & mask)and the ID format matches. - CanFrame
- An immutable classic CAN 2.0 frame (0-8 data bytes).
- CanHex
- Hex encoding helpers for CAN payloads.
- CanId
- A CAN arbitration ID together with its format (11-bit or 29-bit).
- CanLogReplayer
- Replays a candump log onto any CanBus.
- CanUsb
- Entry point for USB OTG CAN adapters on Android.
- DbcDatabase
- A parsed DBC file: decodes frames into signals and encodes signals into frames.
- DbcMessage
-
A message definition (
BO_). - DbcMultiplexed
-
The signal (
mN) is present only when the multiplexor equals value. - DbcMultiplexing
- Multiplexing role of a signal.
- DbcMultiplexor
-
The signal (
M) selects which multiplexed signals are present. - DbcNode
-
A network node (
BU_). - DbcNotMultiplexed
- The signal is always present.
- DbcSignal
-
A signal definition (
SG_). - DecodedMessage
- A frame decoded with a DBC message definition.
- DecodedSignal
- One decoded signal value.
- Dtc
- A two-byte OBD-II (SAE J2012) diagnostic trouble code.
- IsoTpChannel
- An ISO 15765-2 (ISO-TP) connection between two CAN IDs on any CanBus.
- IsoTpOptions
- ISO 15765-2 transport settings.
- ObdClient
- OBD-II (SAE J1979 / ISO 15765-4) client on any CanBus.
- ObdDetection
- Result of ObdClient.autoDetect.
-
ObdEcuResponses<
T> - Responses to one OBD-II request, keyed by the responding CAN ID (for example 0x7E8 for the engine ECU in 11-bit addressing).
- ObdEcuSimulator
-
A simulated ECU that answers OBD-II and UDS requests on any CanBus, for tests
and demos without hardware. Usually run on a
VirtualCanNetworkbus. - ObdPidDefinition
- Definition of a mode 01 / 02 parameter (SAE J1979).
- ObdPids
- Decoders for common mode 01 / 02 PIDs.
- ObdPidSample
-
One sample from
ObdClient.poll. - ObdPidValue
- A decoded (or raw) OBD-II parameter.
- PeriodicTask
- A running periodic transmission created by CanBus.sendPeriodic.
- UdsClient
- UDS (ISO 14229-1) client over ISO-TP with physical addressing.
- UdsDtc
- A DTC reported by UDS service 0x19: 3-byte code plus ISO 14229 status byte.
- UdsDtcCount
-
Response to
reportNumberOfDTCByStatusMask(0x19 0x01). - UsbCanBus
-
A CAN bus on a USB adapter. Obtain one with
CanUsb.open. - UsbCanDevice
- An attached USB CAN adapter that the toolkit recognises.
- UsbDeviceEvent
- A USB attach, detach or permission event for a supported adapter.
- VirtualCanBus
- An in-memory CanBus, either standalone or part of a VirtualCanNetwork.
- VirtualCanNetwork
- An in-memory CAN network connecting several VirtualCanBus instances.
Enums
- CanAdapterType
- USB CAN adapter protocol families.
- CanBitrate
- Classic CAN bitrates supported by the toolkit's adapters.
- CanBusState
- Controller state of a CAN bus connection.
- CanDirection
- Whether a frame was received from the bus or sent by this node.
- DbcByteOrder
- Bit order of a DBC signal.
- DbcValueType
- How the raw bits of a signal are interpreted.
- DtcSystem
- Diagnostic trouble code system, from the two top bits of the code.
- IsoTpPadding
- Whether ISO-TP frames are padded to 8 bytes.
- ObdAddressing
- OBD-II addressing on CAN (ISO 15765-4).
- UdsSession
- UDS diagnostic sessions (service 0x10).
- UsbDeviceEventType
- Kinds of UsbDeviceEvent.
Functions
-
udsNrcName(
int nrc) → String - Readable name of a UDS negative response code (ISO 14229-1 Annex A).
Typedefs
-
SeedKeyFunction
= Future<
Uint8List> Function(Uint8List seed, int level) - Computes a security access key from an ECU seed. The algorithm is OEM-specific and not part of this package.
- SimulatorKeyFunction = Uint8List Function(Uint8List seed, int level)
- Computes the key the simulator expects for a security access seed.
Exceptions / Errors
- CanBusClosedException
- A method was called on a bus that has already been closed.
- CanConfigException
- A frame, filter or bus configuration is invalid or not supported.
- CanDeviceDisconnectedException
- The adapter was unplugged or stopped responding.
- CandumpFormatException
- A malformed line in a candump log.
- CanException
- Base class for errors from bus, transport, diagnostic and parsing operations in can_bus_toolkit. Invalid arguments (a PID above 0xFF, a negative period) are programming errors and throw ArgumentError / RangeError as usual in Dart.
- CanPermissionDeniedException
- The user or system denied access to a USB device.
- CanTimeoutException
- An operation did not complete within its time limit.
- CanWriteNotAllowedException
-
A request that changes vehicle or ECU state was made without
allowWrites: true. - DbcParseException
- A DBC file could not be parsed.
- IsoTpException
- An ISO-TP protocol error: unexpected sequence number, overflow reported by the receiver, or a malformed flow control frame.
- ObdException
- An OBD-II request failed or returned data that cannot be decoded.
- UdsNegativeResponseException
-
A UDS (ISO 14229) negative response
7F <service> <NRC>.