This interface adds support for CAN controllers by National Instruments.


NI-CAN only seems to support 32-bit architectures so if the driver can’t be loaded on a 64-bit Python, try using a 32-bit version instead.


CAN filtering has not been tested throughly and may not work as expected.


class can.interfaces.nican.NicanBus(channel, can_filters=None, bitrate=None, log_errors=True, **kwargs)[source]

Bases: can.bus.BusABC

The CAN Bus implemented for the NI-CAN interface.

  • channel (str) – Name of the object to open (e.g. ‘CAN0’)
  • bitrate (int) – Bitrate in bits/s
  • can_filters (list) –

    A list of dictionaries each containing a “can_id” and a “can_mask”.

    >>> [{"can_id": 0x11, "can_mask": 0x21}]
  • log_errors (bool) – If True, communication errors will appear as CAN messages with is_error_frame set to True and arbitration_id will identify the error (default True)

can.interfaces.nican.NicanError – If starting communication fails


Resets the CAN chip which includes clearing receive and transmit queues.


Read a message from NI-CAN.

Parameters:timeout (float) – Max time to wait in seconds or None if infinite
Returns:The CAN message or None if timeout
Return type:can.Message
Raises:can.interfaces.nican.NicanError – If reception fails
send(msg, timeout=None)[source]

Send a message to NI-CAN.

Parameters:msg (can.Message) – Message to send
Raises:can.interfaces.nican.NicanError – If writing to transmit buffer fails. It does not wait for message to be ACKed currently.

Close object.

exception can.interfaces.nican.NicanError(function, error_code, arguments)[source]

Bases: can.CanError

Error from NI-CAN driver.

arguments = None

Arguments passed to function

error_code = None

Status code

function = None

Function that failed