This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Build CAN message based on user-specified structure


message = canMessage(id, extended, datalength)
message = canMessage(database, messagename)


message = canMessage(id, extended, datalength) creates and returns a CAN message object, from the raw message information.

message = canMessage(database, messagename) constructs a message using the message definition of the specified message, in the specified database.

Input Arguments


The ID of the message that you specify.


Indicates whether the message ID is of standard or extended type. The Boolean value is true if extended or false if standard.


The length of the data of the message, in bytes. Specify from 0 through 8.


Handle to the CAN database containing the message definition.


The name of the message definition in the database.

Output Arguments


The message object returned from the function.


DataCAN message or J1939 parameter group data
DatabaseStore CAN database information
ErrorCAN message error frame
ExtendedIdentifier type for CAN message
IDIdentifier for CAN message
Name (CAN)CAN message name
RemoteSpecify CAN message remote frame
SignalsPhysical signals defined in CAN message or J1939 parameter group
Timestamp (CAN)Display message received timestamp
UserDataEnter custom data


To construct a CAN message, type:

 message = canMessage(2500, true, 4)

To construct a message using CAN database message definitions, create a database object using the canDatabase function, and then construct your message:

candb = canDatabase('c:\database.dbc')
message = canMessage (candb, 'messagename')

Introduced in R2009a

Was this topic helpful?