core library
Core CAN bus types: frames, the CanBus interface, virtual buses,
statistics, candump logging and log replay.
This library has no Flutter or platform dependencies and works with any
CanBus implementation.
import 'package:can_bus_toolkit/core.dart';
final bus = VirtualCanBus();
bus.frames.listen(print);
await bus.send(CanFrame.standard(0x123, [0xDE, 0xAD]));
Classes
- 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.
- PeriodicTask
- A running periodic transmission created by CanBus.sendPeriodic.
- VirtualCanBus
- An in-memory CanBus, either standalone or part of a VirtualCanNetwork.
- VirtualCanNetwork
- An in-memory CAN network connecting several VirtualCanBus instances.
Enums
- 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.
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.