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
canTool Open Vehicle CAN Bus Monitor
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

BusLoadLoad on CAN bus
DatabaseStore CAN database information
OnboardTerminationConfigure bus termination on device
RunningDetermine status of channel
SilentModeSpecify if channel is active or silent
StartTriggerTerminalSpecify start trigger source terminal
TransceiverNameName of device transceiver
TransceiverStateDisplay state or mode of transceiver
UserDataEnter custom data
DeviceDisplay channel device type
Device(NI)Display NI CAN channel device type
DeviceChannelIndexDisplay device channel index
DeviceSerialNumberDisplay device serial number
DeviceVendorDisplay device vendor name
InitializationAccessDetermine control of device channel
BusSpeedBit rate of bus
NumOfSamplesDisplay number of samples available to channel
SJWSynchronization jump width (SJW) of bit time segment
TSEG1Display amount that channel can lengthen sample time
TSEG2Display amount that channel can shorten sample time
DataCAN message or J1939 parameter group data
DatabaseStore CAN database information
ErrorCAN message error frame
ExtendedIdentifier type for CAN message
IDIdentifier for CAN message
Name (CAN)CAN message name
RemoteSpecify CAN message remote frame
SignalsPhysical signals defined in CAN message or J1939 parameter group
UserDataEnter custom data
MessageReceivedFcnSpecify function to run
MessageReceivedFcnCountSpecify number of messages available before function is triggered
MessagesAvailableDisplay number of messages available to be received by CAN channel
MessagesReceivedDisplay number of messages received by CAN channel
MessagesTransmittedDisplay number of messages transmitted by CAN channel
InitialTimestampIndicate when channel started
Timestamp (CAN)Display message received timestamp
ReceiveErrorCountDisplay number of received errors detected by channel
TransmitErrorCountDisplay number of transmitted errors by channel


expand all

Vehicle CAN Bus MonitorMonitor vehicle CAN bus message traffic


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.

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