Main Content

Basic Communication with CAN or CAN FD

Configure CAN hardware; send and receive messages on network

Hardware connection functions define a connection to a CAN interface hardware that establishes a physical connection to a CAN bus. The CAN Transmit Workflow shows how to pack and transmit CAN messages with MATLAB®. You can also employ event-based message transmission; load and replay messages. The CAN Receive Workflow shows how to receive and unpack CAN messages.

For building Simulink® models that use CAN blocks to transmit and receive messages on the network, see CAN Communication in Simulink.


expand all

canChannelListInformation on available CAN devices
canChannelConstruct CAN channel connected to specified device
discardDiscard all messages from CAN channel
configBusSpeedSet bit timing rate of CAN channel
canSupportGenerate technical support log
canMessageBuild CAN message based on user-specified structure
packPack signal data into CAN message
startSet CAN channel online
transmitSend CAN messages to CAN bus
replayRetransmit messages from CAN bus
transmitConfigurationDisplay messages configured for automatic transmission
transmitEventConfigure messages for event-based transmission
transmitPeriodicConfigure messages for periodic transmission
receiveReceive messages from CAN bus
attachDatabaseAttach CAN database to messages and remove CAN database from messages
stopSet CAN channel offline
unpackUnpack signal data from CAN message
extractAllSelect all instances of CAN message from message array
extractRecentSelect most recent CAN message from array of messages
extractTimeSelect CAN messages occurring within specified time range
canMessageImport Import CAN messages from third-party log file
canSignalImportImport CAN log file into decoded signal timetables
canMessageTimetableConvert CAN messages into timetable
canSignalTimetableCreate CAN signal timetable from CAN message timetable
canFDChannelListInformation on available CAN FD device channels
canFDChannelConstruct CAN FD channel connected to specified device
canFDMessageBuild CAN FD message based on user-specified structure
canFDMessageTimetableConvert CAN or CAN FD messages into timetable
canFDMessageReplayBlockStructConvert CAN FD messages for use as CAN Replay block output


expand all

can.Channel PropertiesProperties of the can.Channel object
can.Message PropertiesProperties of the can.Message object


expand all

CAN ExplorerAcquire and visualize CAN data
CAN FD ExplorerAcquire and visualize CAN FD data


Programmatic Workflow

Transmit and Receive CAN Messages

Discover CAN devices and communicate over a network.

Filter Messages

Set up filters to accept messages based on specified parameters.

Configure Silent Mode

Observe and analyze message activity without affecting the network state or behavior.

Multiplex Signals

Use multiplexing to represent multiple signals in one signal location in a CAN message’s data.

MathWorks Virtual Channels

Emulate virtual CAN channels provided with the toolbox.

Tools Workflow

Vehicle CAN Bus Monitor

Explore the Vehicle CAN Bus Monitor.

Using the Vehicle CAN Bus Monitor

Select a CAN device and channel; view, filter, and save messages.

Featured Examples