SocketCAN

Open an existing Linux CAN interface with SocketCanAdapter("can0"), or use "vcan0" for a virtual CAN interface. Bus timing is configured through the operating system; opening the adapter does not change it.

Configuration

The configuration is shared by the async and sync APIs.

class automotive.adapters.SocketCanConfig(*, interface: str = 'can0')[source]

Select an existing Linux SocketCAN interface.

Parameters:

interface – Interface name, default “can0”. Use “vcan0” for tests.

Bus timing is configured through the OS; opening never changes it.

interface: str
backend: ClassVar[str] = 'socketcan'

Asynchronous API

Send, receive, and lifecycle methods are inherited from automotive.adapters.CanAdapter.

class automotive.adapters.SocketCanAdapter(interface: str | SocketCanConfig = 'can0')[source]

Bases: CanAdapter

Open a Linux SocketCAN adapter with SocketCanAdapter('can0').

Parameters:

interface – Interface name, default “can0”, or a reusable SocketCanConfig.

Timing is configured through the OS. Construction opens synchronously.

Synchronous API

Blocking methods are inherited from automotive.sync.adapters.CanAdapter.

class automotive.sync.adapters.SocketCanAdapter(interface: str | SocketCanConfig = 'can0')[source]

Bases: CanAdapter

Open a Linux SocketCAN adapter with SocketCanAdapter('can0').

Parameters:

interface – Interface name, default “can0”, or a reusable SocketCanConfig.

Timing is configured through the OS. Construction opens synchronously.