Main Content

Controller Area Network

R2026b
Communicate with Raspberry Pi® hardware using Controller Area Network (CAN) protocol

Leverage the capabilities of Controller Area Network (CAN) to efficiently design and implement robust and reliable CAN-based communication systems.

Blocks

CAN Transmit blockCAN TransmitTransmit message to CAN network
CAN Receive blockCAN Receive Receive message from CAN network
Icon of the CAN FD Transmit block in the Raspberry Pi Blockset > Communication library.CAN FD TransmitTransmit CAN FD messages over a CAN interface (Since R2026b)
Icon of the CAN FD Receive block in the Raspberry Pi Blockset > Communication library.CAN FD ReceiveReceive CAN FD messages from a CAN interface (Since R2026b)

Objects

canChannelConnection to CAN channel through specified device

Functions

enableCANEnable CAN interface
disableCANDisable CAN interface
readRead messages from CAN channel
writeWrite messages to CAN channel

Model Settings

expand all

Interface configurationCAN interface configuration method (Since R2026b)
Number of interfacesNumber of CAN interfaces to configure
CAN NameSocketCAN interface name
CAN TypeCAN interface type
CAN protocolCAN communication protocol selection (Since R2026b)
Bus speed (kbps)CAN bus bit rate for classical CAN communication
Nominal bitrate (kbps)Arbitration phase bit rate for CAN FD communication (Since R2026b)
Data bitrate (kbps)Data bit rate for CAN FD communication (Since R2026b)
Transmit queue buffer sizeTransmit queue length for SocketCAN interface
Filter configuration (all interfaces)CAN message filtering mode selection (Since R2026b)
ID typeCAN identifier format for acceptance filter
Acceptance MaskCAN identifier bit mask for filtering
Acceptance filterCAN identifier filter value
Inverse filterInvert acceptance filter behavior
Communication interfaceExchange data between host computer and target hardware
Host interfaceSelect host-side interface for XCP external mode communication (Since R2026b)
CAN VendorCAN hardware vendor for XCP on CAN external mode communication (Since R2026b)
CAN DeviceCAN hardware device for XCP on CAN external mode communication (Since R2026b)
CAN ChannelCAN hardware channel for XCP on CAN external mode communication (Since R2026b)
CAN interface nameSocketCAN interface name on the target for XCP on CAN communication (Since R2026b)
Extended CAN IDUse extended 29-bit CAN identifiers for XCP external mode communication (Since R2026b)
CAN ID commandSpecify the CAN identifier for XCP command messages from host to target (Since R2026b)
CAN ID responseSpecify the CAN identifier for XCP response messages from target to host (Since R2026b)
Run external mode in a backgroundForce background-thread execution of the external mode task in the generated code
Logging buffer size (in bytes)Number of bytes to preallocate for buffer in hardware
VerboseView the external mode execution progress and updates
Set logging buffer size automaticallyAutomatically preallocate buffer size (Since R2026a)
Set XCP target polling timeSet XCP-based polling time automatically or manually (Since R2022a)
Polling time (in seconds)Set XCP-based polling time (Since R2022a)

XCP on CAN with Raspberry Pi

Set Up, Deploy, and Calibrate Raspberry Pi Application Using XCP on CAN

Set up XCP on CAN communication, deploy a Simulink® application to Raspberry Pi, and perform real-time monitoring and calibration using Simulink or third-party calibration tools.

Topics

Featured Examples