Main Content

CAN FD Receive

R2026b

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

Since R2026b

  • CAN FD Receive 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 Receive block receives messages by using the time-triggered controller area network (TTCAN) controller on NVIDIA® Jetson™ boards. The block uses the SocketCAN interface to receive CAN frames.

You can use the CAN FD Receive block to receive messages of up to 64 bytes, compared to a maximum of 8 bytes for a CAN Receive block. Additionally, you can enable bit-rate switching on the CAN FD Transmit block so that the CAN FD Receive block receives data at a faster rate. For more information, see Bit-Rate Switching.

Examples

Ports

Output

expand all

Raw message data, returned as a uint8 vector. The Message Length parameter determines the length of the vector.

Dependencies

To enable this port, set Data to be output as to Raw data.

Data Types: uint8

CAN message data, returned as a CAN_FD_MESSAGE_BUS bus. To extract data from the bus signal, use the CAN FD Unpack (Vehicle Network Toolbox) block.

Dependencies

To enable this port, set Data to be output as to CAN Msg.

Status of the received message, returned as a uint8 scalar. If the block receives a message, the status is 1. Otherwise, the status is 0.

Data Types: uint8

Error codes, returned as a uint8 scalar in which each bit indicates a specific error code. For example, if bit zero is 1, the transmission generated an overflow on receive buffer 1. This table lists the error codes for each bit.

Status bitError Code
0Receive Buffer 1 Overflow Flag (RX1OVR)
1Receive Buffer 0 Overflow Flag (RX0OVR)
2Receive Error-Passive Flag (RXEP)
3Receive Error Warning Flag (RXWAR)
4-
5-
6-
7-

Dependencies

To enable this port, select Output Error.

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 returns:

  • Raw data returns a uint8 vector containing the CAN data.

  • CAN Msg returns a Simulink bus containing the CAN frame information.

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: OutputDataType
Values: "Raw Data" (default) | "CAN Msg"

Example: get_param(gcb,"OutputDataType")

Specify the message identifier type:

  • Standard (11-bit identifier) uses the standard, 11-bit identifier.

  • Extended (29-bit identifier) uses the extended, 29-bit identifier.

Dependencies

To enable this parameter, set Data to be output 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 to be output 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 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 to be output 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")

Specify the sample time at which the block reads the port buffer, in seconds. To inherit the sample time from the model, use -1. Otherwise, enter a value greater than 0.

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: SampleTime
Values: "-1" (default) | numeric value in quotes

Example: get_param(gcb,"SampleTime")

Select this parameter to output error codes if the message transfer fails.

Dependencies

To enable this parameter, set Data to be output 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: OutputError
Values: "off" (default) | "on"

Example: set_param(gcb,OutputError="on")

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