Contenuto principale

CAN FD Transmit

R2026b

Transmit messages on controller area network (CAN) bus with flexible data rate

Since R2026b

  • CAN FD Transmit block

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

Ports

Input

expand all

Message data, specified as a uint8 vector or as a CAN_FD_MESSAGE_BUS:

  • To specify the message data as a uint8 vector, set the Data is input as parameter to Raw 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 to CAN Msg. To create a CAN_FD_MESSAGE_BUS signal, use the CAN FD Pack (Vehicle Network Toolbox) block.

Output

expand all

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 bitError Code
0Transmit Error Warning Flag (TXWAR)
1Transmit Error-Passive Flag (TXEP)
2Bus-Off Error Flag (TXBO)
3Transmission Error Detected (TXERR)
4Message Lost Arbitration (MLOA)
5Message Aborted Flag (ABTF)
6-
7-

Dependencies

To enable this port, select Output Status.

Data Types: uint8

Parameters

expand all

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 to 2047. If Identifier Type is set to Extended (29-bit identifier), the message identifier must be less than or equal to 536870911.

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:

  • 64

  • 48

  • 32

  • 24

  • 20

  • 16

  • 12

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

expand all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2026b