CAN FD Replay
Replay logged CAN FD messages
Libraries:
Vehicle Network Toolbox /
CAN FD Communication
Description
The CAN FD Replay block replays logged messages from a .mat
file to a
CAN network or to Simulink® as a bus signal. For more information on Simulink bus objects, see Composite Interfaces (Simulink). You need a CAN FD
Configuration block to replay to the network.
To replay messages logged in the MATLAB® Command window in your Simulink model, convert them into a compatible format using canMessageReplayBlockStruct
and save the result to a separate file. For more
information, see Log and Replay CAN Messages.
Note
You need a license for both Vehicle Network Toolbox™ and Simulink software to use this block.
Replay Timing
The block replays messages using their original timestamps to synchronize with
simulation time (for regular simulations) or wall-clock time (for replay to a physical
network). Specifically, when the Simulink solver advances one time step, the block sends the messages whose timestamps
belong to that time step. Therefore, it is important that the timestamps are consistent with
the time range of the simulation. It is recommended to set the simulation start time to
0
, and to shift the message timestamps so that the initial timestamp is
0
.
For more information, see Start time (Simulink) and the example Log and Replay CAN FD Messages.
Other Supported Features
The CAN FD Replay block supports the use of Simulink accelerator mode. Using this feature, you can speed up the execution of Simulink models. For more information on this feature, see Acceleration (Simulink).
The CAN FD Replay block supports the use of code generation along with the packNGo function to group required source code and dependent shared libraries.
Code Generation
Vehicle Network Toolbox Simulink blocks allow you to generate code, enabling models containing these blocks to run in accelerator, rapid accelerator, external, and deployed modes.
You can use Vehicle Network Toolbox, Simulink Coder™, and Embedded Coder® software together to generate code on the host end that you can use to implement your model. For more information on code generation, see Generated Code Compilation (Simulink Coder).
The block generates code with limited portability. The block uses
precompiled shared libraries, such as DLLs, to support I/O for
specific types of devices. With this block, you can use the
packNGo
function supported by Simulink
Coder to set up and manage the build information for your
models. The packNGo
(Simulink Coder) function
allows you to package model code and dependent shared libraries into
a zip file for deployment. You do not need MATLAB installed on the target system, but the target system
needs to be supported by MATLAB.
To set up packNGo
:
set_param(gcs,'PostCodeGenCommand','packNGo(buildInfo)');
In this example, gcs
is the current model that you
want to build. Building the model creates a zip file with the same name as
model name. You can move this zip file to another machine and there build
the source code in the zip file to create an executable which can run
independent of MATLAB and Simulink. The generated code compiles with both C and C++ compilers.
For more information, see Code Compilation Customization (Simulink Coder).
Note
On Linux® platforms, you need to add the folder where
you unzip the libraries to the environment variable
LD_LIBRARY_PATH
.
Examples
Ports
Output
Parameters
Extended Capabilities
Version History
Introduced in R2018b