obd library
ISO-TP (ISO 15765-2), OBD-II (SAE J1979) and UDS (ISO 14229) clients that run on
top of any CanBus, plus a simulated ECU for tests and demos.
Reading is always allowed. Services that change vehicle or ECU state (OBD mode
04, UDS session control, write DID, clear DTCs, security access) need an explicit
allowWrites: true.
import 'package:can_bus_toolkit/obd.dart';
final obd = ObdClient(bus);
print((await obd.readPid(0x0C)).first); // Engine speed: 1726 rpm
print((await obd.readVin()).first);
Classes
- 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.
- 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).
Enums
- 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).
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
- CanWriteNotAllowedException
-
A request that changes vehicle or ECU state was made without
allowWrites: true. - 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>.