Main Content

CAN Transmit

Transmit messages on the controller area network (CAN) bus

  • Library:
  • NVIDIA Jetson and NVIDIA DRIVE / Communication

  • NVIDIA CAN receive block

Description

The CAN Transmit block transmits messages on the CAN bus through the time triggered CAN (TTCAN) controller available on NVIDIA® embedded boards. This block uses the SocketCAN interface to communicate with the CAN controller hardware on NVIDIA boards.

You can also use this block to interact with a virtual CAN interface. A virtual CAN interface allows transmission and reception of CAN frames without a native CAN interface associated with real hardware. For more information on how to set up a virtual CAN interface, see Setup Virtual CAN Interface.

The CAN Transmit block supports Raw data and CAN Msg as input types. To use CANdb (CAN database) file or to specify signals manually, use CAN Msg input type and CAN Pack block. The CAN Pack block is available from the Vehicle Network Toolbox™.

Ports

Input

expand all

Message data, specified as vector or scalar.

Data Types: uint8 | CAN Msg

Output

expand all

Output status.

Dependencies

To enable this parameter, select Output Status

Parameters

expand all

Device ID of the CAN controller to use.

Programmatic Use

Block Parameter: DeviceID
Type: character vector
Values: valid CAN ID
Default: 'can0'

Select this parameter to bring up the CAN interface on the NVIDIA target before transmitting CAN frames.

Programmatic Use

Block Parameter: SetupCAN
Type: character vector
Values:'off'|'on'
Default: 'off'

Select the type of CAN interface.

  • If the CAN interface type is Real, set this parameter to Real. Setting this parameter to Real would not bring up the CAN interface in these scenarios.

    • The interface is already brought up on the target with a CAN-Bus Speed that does not match with the CAN Bus Speed (kBit/s) parameter. The block would not transmit the CAN frames. Bring the existing interface down before enabling this parameter.

    • If the interface is already brought up on the target with the CAN-Bus Speed that matches with the CAN Bus Speed (kBit/s) parameter. The block will transmit the CAN frames.

  • If the CAN interface type is Virtual, set this parameter to Virtual.

Dependencies

To enable this parameter, select Set up CAN interface.

Programmatic Use

Block Parameter: TypeofCAN
Type: character vector
Values:'Real'|'Virtual'
Default: 'Real'

Data input type used for transmitting messages.

Programmatic Use

Block Parameter: InputDataType
Type: character vector
Values: 'Raw data'|'CAN Msg'
Default: 'Raw data'

Select this option to indicate the status of message transfer. Status port outputs 0 for successful transmit and error codes in case of failure. Error codes are listed in this table.

0000ABTFMLOATXERRTXBOTXEPTXWAR
bit7bit6bit5bit4bit3bit2bit1bit0

ABTF: Message Aborted Flag bit

MLOA: Message Lost Arbitration bit

TXERR: Transmission Error Detected bit

TXBO: Bus-Off Error Flag bit

TXEP: Transmit Error-Passive Flag bit

TXWAR: Transmit Error Warning Flag bit

Programmatic Use

Block Parameter: OutputStatus
Type: character vector
Values:'off'|'on'
Default: 'off'

When selected, the block waits for the time specified in the Time out in seconds parameter before transferring data.

Programmatic Use

Block Parameter: BlockingMode_
Type: character vector
Values:'off'|'on'
Default: 'off'

Wait time for transferring data. After the specified time, the block times out.

Dependencies

To enable this parameter, select Wait until data sent.

Programmatic Use

Block Parameter: BlockTimeout_
Type: character vector
Values: scalar | vector
Default: '1'

Message identifier type.

Dependencies

To enable this parameter, set Data is input as to Raw data.

Programmatic Use

Block Parameter: IdentifierType
Type: character vector
Values: 'Standard (11-bit identifier)'|'Extended (29-bit identifier)'
Default: 'Standard (11-bit identifier)'

Message identifier, which is 11 bits long for the standard frame size or 29 bits long for the extended frame size, specified in decimal, binary, or hex. For binary and hex formats, use bin2dec(' ') and hex2dec(' '), respectively, to convert the entry. The message identifier is coded into a message that is sent to the CAN bus.

Dependencies

To enable this parameter, set Data is input as to Raw data.

Programmatic Use

Block Parameter: MessageId
Type: character vector
Values: '100'|scalar
Default: '100'

Message length.

Dependencies

To enable this parameter, set Data is input as to Raw data.

Programmatic Use

Block Parameter: MsgLength
Type: character vector
Values: '8'|scalar
Default: '8'

When selected, this block sends request for remote frames.

Dependencies

To enable this parameter, set Data is input as to Raw data.

Programmatic Use

Block Parameter: RemoteFrame
Type: character vector
Values:'off'|'on'
Default: 'off'

Tips

  • If a Simulink® model contains CAN Transmit and CAN Receive block, and the Set up CAN interface is set only on the CAN Transmit block, then a CAN receive socket might not be set up because of the order of execution of the blocks. In such cases, manually set up the CAN interfaces before executing the models or enable Set up CAN interface on all blocks.

Version History

Introduced in R2021b