## Key Features

• MATLAB functions for transmitting and receiving CAN and J1939 messages
• Simulink blocks for connecting a model to a CAN or J1939 bus
• XCP support for communicating with ECUs
• Vector CAN database (.dbc) file and A2L description file support
• Signal packing and unpacking for simplified encoding and decoding of CAN messages and J1939 parameter groups
• Vehicle CAN Bus Monitor app to configure devices and visualize live CAN network traffic
• Support for Vector, Kvaser, PEAK-System, and National Instruments® CAN interface devices
Simulink model illustrating a host model for host-target CAN communication. This host model enables the exchange of CAN messages between the host model on your PC and a target model running on your target hardware.

Vehicle Network Toolbox lets you interact directly with a CAN bus from MATLAB® or Simulink®. You can execute toolbox functions from the MATLAB command line and through MATLAB programs. The toolbox also contains Simulink blocks that enable you to connect a Simulink model to a CAN bus.

### Configuring CAN Channels

CAN channel functions in MATLAB and CAN configuration blocks in Simulink enable you to define a connection to Vector CAN interface hardware that establishes a physical connection with a CAN bus. The toolbox provides CAN channel functions to query and configure CAN interface hardware settings, such as bus speed and transceiver settings. You can also verify other CAN channel properties, such as the number of messages available and the number of messages received or transmitted on the channel. By attaching Vector CAN database files to CAN channels, incoming messages are automatically presented using information stored in the database. After defining a CAN channel, you can send and receive CAN messages on the channel.

### Sending and Receiving CAN Packets

CAN messages contain properties for storing the CAN message identifier (standard 11-bit or extended 29-bit), the time stamp, and up to 8 bytes of CAN data. Transmit and receive functions and blocks in the toolbox enable the sending and receiving of CAN messages over CAN channels. For large data sets, you can log CAN messages for offline analysis.

### Building and Extracting Signals from CAN Messages

Vehicle Network Toolbox provides functions and blocks for encoding and decoding CAN messages. CAN message data may contain data representing multiple signals. Unpack functions and blocks let the user specify start bit, signal length, data type, and byte ordering. Pack functions and blocks provide the same options for building up data for CAN message transmission.

### Logging and Replaying CAN messages

Using the CAN Log block in the toolbox, you can save CAN messages received by your model to a MAT-file. You can then use the CAN Replay block to replay the messages in another Simulink model. The CAN Replay block preserves the time stamps of the logged data so the replayed data will have the same timing characteristics as the recorded data.

## Communicating over the XCP Protocol

Vehicle Network Toolbox provides functions and blocks for communicating with ECUs via XCP—an automotive calibration protocol—over CAN bus. When communicating with ECUs over XCP, MATLAB or Simulink is the master and the ECUs are slave devices. You can communicate with multiple ECUs by opening multiple XCP channels. For each ECU, you can read and write data to specific memory locations within the ECU. When secured access to an ECU exists, you can use seed and key security to open access to the ECU. The toolbox also provides functions and blocks for linking A2L database files and for creating and viewing dynamic DAQ and STIM measurement lists for an XCP channel. These lists are established based on measurement and event information from the linked A2L file.

Model for acquiring measurements from an ECU slave device. The model uses XCP Configuration and XCP Transport Layer blocks (top left), and XCP Data Acquisition blocks (bottom left) to set up the acquisition of the PWM signal (right).

## Communicating Over J1939 Protocol

Vehicle Network Toolbox provides functions and blocks for communicating via J1939 — a CAN based high-level protocol commonly used in the heavy-duty truck industry. When communicating over J1939, you use MATLAB functions or Simulink blocks to set up the communication. Specifically, functions and blocks are provided to associate a database (.dbc) file to the J1939 communication, to specify the CAN interface hardware, and to transmit and receive J1939 parameter groups. You encode and decode signal data on the network by using parameter groups defined by the database file associated with the connection. Additionally, you can configure Simulink to operate as network nodes with address claiming.

Model for sending and receiving J1939 data using the J1939 Transmit and J1939 Receive blocks. The model also uses J1939 Network Configuration, J1939 CAN Transport Layer Configuration, and J1939 Node Configuration blocks to set up the communication.

## Visualizing CAN Traffic

The toolbox provides a Vehicle Network CAN Bus Monitor app for visualizing active traffic on a particular CAN channel. You can use the app while performing other tasks in MATLAB or Simulink. For CAN database files associated with your CAN channel, the app decodes the messages and displays them in their correct engineering units.

When traffic on the network contains more information than needed for your application, you can limit the number of CAN messages received by a CAN channel to a defined range of CAN message identifiers. Using filter functions and mask settings in the toolbox, you receive only the messages needed for your application.

Live CAN bus traffic on the network displayed by the Vehicle CAN Bus Monitor app. The display shows raw data; it can be configured to show decoded data when the CAN channel is associated with a .dbc database file.

## Using Vector CAN Database Files

Vehicle Network Toolbox lets you associate a Vector CAN database file with a CAN channel or message from MATLAB or Simulink, enabling you to encode and decode CAN messages using application-specific message and signal names such as EngineMsg and EngineRPM, as well as scaled engineering units. The ability to work with industry-standard database files simplifies the interaction with the CAN bus because the database not only specifies the message list and component signals, but also provides the bit packing and unpacking rules for the associated signals. Because signal data type, start bit, length, and byte order are all predefined for the messages in the database, you can focus on analyzing your signals rather than on defining them.

Code example showing how to view messages using information stored in CAN database files.

## Using A2L Description Files

Vehicle Network Toolbox lets you use industry-standard A2L (also known as ASAP2) description files to communicate with ECUs over the XCP protocol from MATLAB or Simulink. Using A2L description files enables you to access internal ECU parameters from a MATLAB program or a Simulink model. A2L description files contain information about the associated memory address for a particular parameter, the storage structure, and the data type. The files also contain rules for converting stored values such as system parameters, sensor characteristics, and correction factors into physical units such as RPM and degrees Celsius. Having this data lets you easily perform calibration and measurement tasks without needing to parse data and decode memory addresses.

Code example showing how to access information stored in A2L files for use with XCP connections. It uses a freely available XCP slave simulator from Vector and Vector Virtual CAN channels.