CAN FD Transmit
R2026bTransmit messages on controller area network (CAN) bus with flexible data rate
Since R2026b
CAN FD Transmit block
To add a block to a model, double-click the canvas and start typing the block name. Then, select the block from the list.
Libraries:
NVIDIA Jetson and NVIDIA DRIVE /
Communication
Description
Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.
The CAN FD Transmit block transmits messages on the time-triggered CAN (TTCAN) controller on NVIDIA® Jetson™ boards. The block uses the SocketCAN interface to transmit CAN frames.
You can use the CAN FD Transmit block to send messages of up to 64 bytes, compared to messages of at most 8 bytes for a CAN Transmit block. Additionally, you can enable bit-rate switching so that the block transmits data at a faster rate than the CAN Transmit block. For more information, see Bit-Rate Switching.
Examples
Send and Receive CAN FD Messages on NVIDIA Jetson
Use the CAN FD communication protocol on a Jetson board from Simulink®.
- Since R2026b
- Open Live Script
Ports
Input
Message data, specified as a uint8 vector or as a
CAN_FD_MESSAGE_BUS:
To specify the message data as a
uint8vector, set the Data is input as parameter toRaw Data. The number of elements in the vector must match the Message length parameter.To specify the message data as a
CAN_FD_MESSAGE_BUS, set the Data is input as block parameter toCAN Msg. To create aCAN_FD_MESSAGE_BUSsignal, use the CAN FD Pack (Vehicle Network Toolbox) block.
Output
Output status, returned as a scalar. This port outputs 0 for a
successful transmission. If transmission
fails, the status is a uint8 value where each bit indicates a
specific error code. For example, if bit zero is equal to 1, the
transmission generated a transmit error warning flag. This table lists the error codes
for each bit.
| Status bit | Error Code |
|---|---|
| 0 | Transmit Error Warning Flag (TXWAR) |
| 1 | Transmit Error-Passive Flag (TXEP) |
| 2 | Bus-Off Error Flag (TXBO) |
| 3 | Transmission Error Detected (TXERR) |
| 4 | Message Lost Arbitration (MLOA) |
| 5 | Message Aborted Flag (ABTF) |
| 6 | - |
| 7 | - |
Dependencies
To enable this port, select Output Status.
Data Types: uint8
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Name of the real or virtual CAN interface.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | DeviceID |
| Values: | "can0" (default) | interface name in quotes |
| Data Types: | string | char |
Example: set_param(gcb,DeviceID="vcan0")
Option to set up the CAN interface specified in the CAN Interface parameter on the NVIDIA target. If you select this parameter, the block configures the network interface before CAN communication.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | SetupCAN |
| Values: | "off" (default) | "on" |
Example: set_param(gcb,SetupCAN="on")
Select the type of CAN interface to set up on the hardware board.
Dependencies
To enable this parameter, select Set up CAN interface.
Note
If you set this parameter to Real, and the CAN
interface specified in the CAN interface parameter
already exists on the board, the CAN bus speed must match the CAN Bus
Speed (kBit/s) model configuration parameter. Otherwise, the
block does not transmit the CAN frames.
Programmatic Use
To set the block parameter value
programmatically, use the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | TypeOfCAN |
| Values: | "Real" (default) | "Virtual" |
Example: set_param(gcb,TypeOfCAN="Virtual")
Specify the data type that the block accepts. Set this parameter to Raw
data to input values of the uint8 data type or
CAN Msg to input CAN messages.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | InputDataType |
| Values: | "Raw data" (default) | "CAN Msg" |
Example: set_param(gcb,InputDataType="CAN
Msg")
Option to switch between nominal and data rate during transmission:
When you select this parameter, the block enables the bit-rate switching (BRS) bit in the CAN FD message. After the receiving CAN node determines the highest-priority message identifier, the CAN FD Transmit block sends data using a faster data rate. If you also select the Set up CAN interface block parameter, the block uses the rate specified in the CAN Data Bitrate (kBit/s) parameter for the data rate. Otherwise, if the CAN interface exists, the block uses the data rate assigned to the interface.
If you clear this parameter, the block sends the entire CAN FD frame by using the nominal rate. If you also select the Set up CAN interface parameter, the message uses the rate specified in the CAN Bus Speed (kBit/s) parameter. Otherwise, the block uses the bus speed assigned to the interface.
Dependencies
To enable this parameter, set Data is input as to
Raw data.
Note
To enable bit-rate switching for CAN Msg input data,
enable bit-rate switching in the CAN FD Pack (Vehicle Network Toolbox)
block.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | EnableBitRateSwitching |
| Values: | "on" (default) | "off" |
Example: set_param(gcb,EnableBitRateSwitching="off")
Select this parameter to use the block in blocking mode. If the block receives message data to send while it is sending data from a previous time step, the block waits for the time specified in Time out in seconds to finish transmitting data. The block then sends the new message data.
When you clear this parameter, the block operates in nonblocking mode. If the block receives message data to send while it is sending data from a previous time step, the block drops the message data.
Note
If you select this parameter and the block sends data after the time specified in Time out in seconds elapses, the task overruns. To avoid overruns, increase the sample time of the block or reduce the message length.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | BlockingMode_ |
| Values: | "off" (default) | "on" |
Example: set_param(gcb,BlockingMode_="on")
Wait time before sending additional data. After the specified amount of time, the block times out.
Dependencies
To enable this parameter, select Wait until data sent.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | BlockTimeout_ |
| Values: | "1" (default) | positive integer in quotes |
| Data Types: | string | char |
Example: set_param(gcb,BlockTimeout_="2")
Select this parameter to output the status of message transfer.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | OutputStatus |
| Values: |
"off"
(default) |
"on"
|
Specify whether to use the standard or extended message identifier type. You can specify the length of the message identifier as 11 or 29 bits.
Dependencies
To enable this parameter, set Data is input as to
Raw data.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | IdentifierType |
| Values: | "Standard (11-bit identifier)" (default) | "Extended (29-bit identifier)" |
Example: get_param(gcb,"IdentifierType")
Message identifier for the CAN frame. For identifiers in binary or hexadecimal formats,
convert the identifier to the decimal format by using the bin2dec or hex2dec functions.
Dependencies
To enable this parameter, set Data is input as to
Raw data.If Identifier Type is
Standard (11-bit identifier), the message identifier must be less than or equal to2047. If Identifier Type is set toExtended (29-bit identifier), the message identifier must be less than or equal to536870911.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | MessageId |
| Values: | "100" (default) | nonnegative integer in quotes |
| Data Types: | string | char |
Example: set_param(gcb,MessageId="2047");
Example: set_param(gcb,MessageId=string(bin2dec("00000001111")));
Message length. Specify the length as an integer between 1 and
8, or one of these values:
64483224201612
Dependencies
To enable this parameter, set Data is input as to
Raw data.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | MsgLengthFD |
| Values: |
"64"
(default) |
"48"
|
"32"
|
"24"
| ... |
Example:
set_param(gcb,MsgLengthFD="32")
More About
In the CAN FD protocol, you can use bit-rate switching to switch between a nominal and data rate during transmission. During the arbitration phase of CAN transmission, nodes on the CAN network send their arbitration fields by using the nominal rate. The receiving node determines the message with the highest priority based on the message identifiers in the arbitration fields. If the Bit-Rate Switching (BRS) bit is on, the node with the highest-priority message sends message data by using a separate, faster data rate. This illustration shows which rates the CAN sender uses for different parts of a CAN FD frame.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2026b
See Also
Blocks
Model Settings
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
