ISO-TP

Software ISO-TP exchanges complete messages over a CAN adapter. IsoTPConfig is shared by the async and sync implementations.

When transmit STmin is zero, both APIs queue consecutive frames in bounded batches within the peer’s block limit. Every frame’s transmit confirmation is awaited before completing the block or transfer, without a timer delay between frames. Batching is enabled by default. For adapters that reorder queued frames, use IsoTPConfig(tx_id=0x7A1, batch_send=False) in either API to confirm each consecutive frame before submitting the next one.

Asynchronous API

Software ISO-TP on top of any supported CAN adapter.

All framing, flow control, separation timing, and validation run in Rust. Create a receive subscription before sending when exchanging raw PDUs.

class automotive.transports.isotp.IsoTP(adapter: CanAdapter, config: IsoTPConfig)[source]

A complete-message ISO-TP transport retaining its CAN adapter.

Parameters:
  • adapter – Open CAN adapter.

  • config – Explicit ISO-TP configuration; only its tx_id is required.

Closing this transport ends its operations without closing the shared CAN adapter. Closing the adapter invalidates this transport and its UDS clients. Drop or close raw receivers before issuing UDS requests on this transport, because both consume PDUs and may send flow-control frames. Sending an empty or oversized payload raises ValueError. Framing and peer rejection failures raise IsoTPError; receive and transmit deadlines raise TimeoutError.

classmethod from_id(adapter: CanAdapter, tx_id: int | Identifier) → Self[source]

Create a transport using default configuration and a derived RX ID.

Parameters:
  • adapter – Open CAN adapter.

  • tx_id – Integer or explicit transmit identifier.

Raises:

ValueError – The transmit or derived receive ID is out of range.

async aclose() → None

Release hardware and wake pending operations; repeated calls are safe.

property closed: bool

Whether this resource or its owning parent has been closed.

recv() → Receiver[bytes]

Subscribe immediately to complete received PDUs as bytes.

Returns:

An async iterator with aclose and async context management.

Subscribe before sending. Closing this receiver releases its subscription. A receive deadline raises TimeoutError; another anext may continue.

async send(data: bytes | bytearray | memoryview) → None

Transmit one complete PDU using the transport’s framing and limits.

Parameters:

data – Bytes, bytearray, or contiguous byte-oriented memoryview.

Transport failures raise the corresponding protocol or connection error. A transmission deadline raises TimeoutError.

class automotive.transports.isotp.IsoTPConfig(*, tx_id: int | Identifier, rx_id: int | Identifier | None = None, rx_id_offset: int | None = None, bus: int = 0, fd: bool = False, padding: int | None = 204, timeout: float = 1.0, separation_time_min: float | None = None, batch_send: bool = True, ext_address: int | None = None, rx_ext_address: int | None = None, max_dlen: int | None = None, block_size: int = 0, receive_separation_time_min: float = 0.0)[source]

Reusable ISO-TP settings, validated and resolved by Rust.

Parameters:
  • tx_id – Required transmit ID, integer or explicit Identifier.

  • rx_id – Receive ID; None derives standard TX+8 or swaps the low two bytes of an extended ID. These are convenience mappings.

  • rx_id_offset – Alternative standard-ID offset, exclusive with rx_id.

  • bus – CAN bus index, default zero.

  • fd – Select CAN FD, default False.

  • padding – Optional padding byte, default 0xCC. None disables optional padding; FD still pads to a valid DLC.

  • timeout – Per-stage transport deadline in seconds, default 1.0. Covers CAN confirmation, flow control, consecutive frames, and idle receive.

  • separation_time_min – Transmit STmin override in seconds; None follows the peer’s advertised value.

  • batch_send – Batch consecutive frames when transmit STmin is zero, default True. Set False for adapters that reorder queued frames; each frame is then confirmed before submitting the next one.

  • ext_address – Optional transmit and default receive address byte.

  • rx_ext_address – Alternate receive address byte; requires ext_address.

  • max_dlen – Transmit data length including the address byte. None selects 8 for Classic or 64 for FD. Classic requires 8; FD also permits 12, 16, 20, 24, 32, and 48.

  • block_size – Advertised receive block size, default zero (unlimited).

  • receive_separation_time_min – Advertised receive STmin in seconds, default zero; rounded up to a wire value and limited to 0.127.

Raises:

ValueError – Rust rejects an ID mapping, length, or timing setting.

Durations must be finite and nonnegative; timeout must be greater than zero. Use resolved_rx_id to inspect the derived receive identifier.

tx_id: int | Identifier
rx_id: int | Identifier | None
rx_id_offset: int | None
bus: int
fd: bool
padding: int | None
timeout: float
separation_time_min: float | None
batch_send: bool
ext_address: int | None
rx_ext_address: int | None
max_dlen: int | None
block_size: int
receive_separation_time_min: float
property resolved_rx_id: Identifier

The explicit or Rust-derived receive ID, preserving its format.

Synchronous API

class automotive.sync.transports.isotp.IsoTP(adapter: CanAdapter, config: IsoTPConfig)[source]

A blocking complete-message ISO-TP transport retaining its CAN adapter.

Parameters:
  • adapter – Open synchronous CAN adapter.

  • config – Shared ISO-TP configuration; only tx_id is required.

Closing this transport leaves the CAN adapter open. Closing the adapter invalidates this transport and its clients. Drop or close raw ISO-TP receivers before issuing UDS requests on the same transport. Sending an empty or oversized payload raises ValueError. Framing and peer rejection failures raise IsoTPError; receive and transmit deadlines raise TimeoutError.

property config: IsoTPConfig

The shared ISO-TP configuration used by this transport.

classmethod from_id(adapter: CanAdapter, tx_id: int | Identifier) → Self[source]

Create a transport with defaults and a Rust-derived receive ID.

Parameters:
  • adapter – Open synchronous CAN adapter.

  • tx_id – Integer or explicit transmit identifier.

close() → None

Release the resource and wake pending operations; idempotent.

property closed: bool

Whether this resource or its owning parent has been closed.

recv() → Receiver[bytes]

Subscribe immediately to complete received PDUs as bytes.

Returns:

A blocking iterator supporting with and close(). Subscribe before sending. A receive deadline raises TimeoutError; next() can resume.

send(data: bytes | bytearray | memoryview) → None

Transmit one complete PDU, blocking until the transport completes it.

Parameters:

data – Bytes, bytearray, or contiguous byte-oriented memoryview.

Transport failures raise the corresponding protocol or connection error. A transmission deadline raises TimeoutError.