J2534¶
Open a Windows SAE J2534 PassThru adapter for raw CAN with J2534Adapter, or
use J2534NativeIsoTP for firmware-managed ISO-TP and reusable device handles.
The vendor DLL must match the Python process’s architecture.
Configuration¶
The configuration is shared by the async and sync APIs. J2534Config() discovers
the vendor DLL from the Windows registry and uses 500 kbit/s Classic CAN.
- class automotive.adapters.J2534Config(*, bitrate: BitrateSettings | None = None, dll_path: str | None = None)[source]¶
Configure a Windows SAE J2534 PassThru adapter.
- Parameters:
dll_path – Vendor DLL path; None discovers it from the Windows registry.
bitrate – Timing inputs; None selects 500 kbit/s Classic CAN.
Use with J2534Adapter for raw CAN, or J2534NativeIsoTP.open for firmware-managed ISO-TP. The vendor DLL must support the Python process’s architecture and concurrent native ISO-TP read/write calls.
- dll_path: str | None¶
- backend: ClassVar[str] = 'j2534'¶
- bitrate: BitrateSettings | None¶
- property resolved_bitrate: BitrateConfig | None¶
Calculated timing for this backend, including its defaults.
Asynchronous API¶
Raw CAN¶
Send, receive, and lifecycle methods are inherited from
automotive.adapters.CanAdapter.
- class automotive.adapters.J2534Adapter(config: J2534Config | None = None)[source]¶
Bases:
CanAdapterOpen a Windows J2534 raw CAN adapter immediately.
- Parameters:
config – Reusable J2534Config; None discovers a DLL and uses Rust defaults.
For firmware-managed ISO-TP, use J2534NativeIsoTP instead.
Native ISO-TP¶
Windows J2534 native ISO-TP and reusable PassThru device handles.
- class automotive.adapters.j2534.J2534Config(*, bitrate: BitrateSettings | None = None, dll_path: str | None = None)[source]¶
Configure a Windows SAE J2534 PassThru adapter.
- Parameters:
dll_path – Vendor DLL path; None discovers it from the Windows registry.
bitrate – Timing inputs; None selects 500 kbit/s Classic CAN.
Use with J2534Adapter for raw CAN, or J2534NativeIsoTP.open for firmware-managed ISO-TP. The vendor DLL must support the Python process’s architecture and concurrent native ISO-TP read/write calls.
- property resolved_bitrate: BitrateConfig | None¶
Calculated timing for this backend, including its defaults.
- class automotive.adapters.j2534.J2534Device(native: _Device)[source]¶
A reusable device returned by a native transport’s into_device method.
Opening a new channel consumes this handle. Dropping its last owner releases the device; aclose() supports early cleanup. Creating multiple channels concurrently is unsupported.
- 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.
- class automotive.adapters.j2534.J2534NativeIsoTP(config: IsoTPConfig, adapter_config: J2534Config | None = None)[source]¶
Firmware-managed ISO-TP transport; use the asynchronous open factory.
The vendor DLL must support concurrent read/write calls. Native J2534 uses Rust’s existing ISO-TP configuration subset; bus, fd, and max_dlen do not configure a native ISO15765 channel. Other fields follow Rust behavior.
- async classmethod open(config: IsoTPConfig, adapter_config: J2534Config | None = None) Self[source]¶
Open a device and native channel without blocking the Python loop.
- Parameters:
config – ISO-TP addressing, padding, timing, and flow-control settings.
adapter_config – DLL selection and bitrate; None discovers the DLL and uses 500 kbit/s Classic CAN.
- Returns:
An open transport supporting async with and UDSClient.
- Raises:
NotSupportedError – Native J2534 is unavailable on this platform/build.
AdapterError – The vendor device or channel could not be opened.
- async classmethod new_on_device(device: J2534Device, config: IsoTPConfig, adapter_config: J2534Config | None = None) Self[source]¶
Consume a reusable device to open the next native ISO-TP channel.
The handle is consumed even if channel opening fails, matching Rust. No requests may be issued on the previous channel after transfer.
- async into_device() J2534Device[source]¶
Close this channel and retain its device for reuse.
- Returns:
A device handle consumable by new_on_device. Existing clients and receivers are invalidated. Close the returned handle after use.
- 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.
Synchronous API¶
Raw CAN¶
Blocking methods are inherited from automotive.sync.adapters.CanAdapter.
- class automotive.sync.adapters.J2534Adapter(config: J2534Config | None = None)[source]¶
Bases:
CanAdapterOpen a Windows J2534 raw CAN adapter immediately.
- Parameters:
config – Reusable J2534Config; None discovers a DLL and uses Rust defaults.
Use J2534NativeIsoTP for firmware-managed ISO-TP.
Native ISO-TP¶
automotive.sync.adapters.j2534 exposes the same native transport and reusable
device handles with blocking calls. Its transport inherits send, receive, and
lifecycle methods from automotive.sync.transports.Transport.
- class automotive.sync.adapters.j2534.J2534NativeIsoTP(config: IsoTPConfig, adapter_config: J2534Config | None = None)[source]¶
Firmware-managed Windows ISO-TP; create it with open().
The vendor DLL must support concurrent reads and writes. Configuration follows the async native transport, including its ISO15765 limitations.
- property adapter_config: J2534Config¶
DLL selection and bitrate used to open this native channel.
- classmethod open(config: IsoTPConfig, adapter_config: J2534Config | None = None) Self[source]¶
Open a J2534 device and native ISO-TP channel, blocking until ready.
- Parameters:
config – Shared ISO-TP addressing and flow-control settings.
adapter_config – DLL selection and bitrate; None uses Rust defaults.
- Returns:
An open transport supporting ordinary with and synchronous UDSClient.
- Raises:
NotSupportedError – Native J2534 is unavailable on this platform.
AdapterError – The vendor device or channel could not be opened.
- classmethod new_on_device(device: J2534Device, config: IsoTPConfig, adapter_config: J2534Config | None = None) Self[source]¶
Consume a reusable device to open the next native ISO-TP channel.
The previous channel’s clients and receivers remain invalidated. The device handle is consumed even if opening fails, matching Rust.
- into_device() J2534Device[source]¶
Close this channel and return its device for reuse or explicit closure.
Existing clients and receivers are invalidated. Pass the returned device to new_on_device() to open another native channel.
- class automotive.sync.adapters.j2534.J2534Device(resource: R)[source]¶
A reusable J2534 device obtained from into_device().
Dropping the last owner releases the device; with and close() support early cleanup. Opening a new native channel consumes this handle, even if opening fails. Concurrent channels on the same device are unsupported.
- close() None¶
Release the resource and wake pending operations; idempotent.
- property closed: bool¶
Whether this resource or its owning parent has been closed.