Main Content

canFDMessage

Build CAN FD message based on user-specified structure

Description

message = canFDMessage(id,extended,datalength) creates a CAN FD message object from the raw message information.

message = canFDMessage(candb,messagename) creates a message using the message definition in the specified database. Because ProtocolMode is defined in the message database, you cannot specify it as an argument to canFDMessage when using a database.

example

Examples

collapse all

Create a CAN FD message using the definitions of a CAN database.

candb = canDatabase("C:\myVNTData\CANFDExample.dbc");
message3 = canFDMessage(candb,"CANFDMessage")
message3 = 

  Message with properties:

   Message Identification
    ProtocolMode: 'CAN FD'
              ID: 1
        Extended: 0
            Name: 'CANFDMessage'

   Data Details
       Timestamp: 0
            Data: [1x48 uint8]
         Signals: []
          Length: 48
             DLC: 14

   Protocol Flags
             BRS: 1
             ESI: 0
           Error: 0

   Other Information
        Database: [1×1 can.Database]
        UserData: []

Create a CAN FD message with a standard ID format.

message2 = canFDMessage(1000,false,64)
message2 = 

  Message with properties:

   Message Identification
    ProtocolMode: 'CAN FD'
              ID: 1000
        Extended: 0
            Name: ''

   Data Details
       Timestamp: 0
            Data: [1×64 uint8]
         Signals: []
          Length: 64
             DLC: 15

   Protocol Flags
             BRS: 0
             ESI: 0
           Error: 0

   Other Information
        Database: []
        UserData: []

Input Arguments

collapse all

ID of the message, specified as a numeric value. If this ID used an extended format, set the extended argument true.

Example: 2500

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specifies whether the message ID is of standard or extended type, specified as true or false. The logical value true indicates that the ID is of extended type (29 bits), false indicates standard type (11 bits).

Example: true

Data Types: logical

The length of the message data, specified as an integer value of 0 through 64, inclusive.

Example: 64

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

CAN database, specified as a database object. The database contains the message definition.

Example: candb = canDatabase('CANDatabase.dbc')

The name of the message definition in the database, specified as a character vector or string.

Example: 'VehicleDataMulti'

Data Types: char | string

Output Arguments

collapse all

CAN FD message, returned as a CAN message object, with the following properties:

PropertyPurpose
BRSCAN FD bit rate switch, as true or false
Data

Data of CAN message or J1939 parameter group

Database

CAN database information

DLCData length code value
Error

CAN message error frame, as true or false

ESICAN FD error state indicator, as true or false
Extended

True of false indication of extended CAN Identifier type

ID

Identifier for CAN message

LengthMessage length in bytes
Name

CAN message name

ProtocolModeProtocol mode defined as CAN or CAN FD
Remote

Specify if CAN message is remote frame

Signals

Physical signals defined in CAN message or J1939 parameter group

Timestamp

Message received timestamp

UserData

Custom data

Version History

Introduced in R2018b