This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Other Uses of the CAN Database

View Message Information in a CAN Database

You can look up information on message definitions by a single message by name, or a single message by ID. You can also look up information on all message definitions in the database by typing:

msgInfo = messageInfo(database name)

This command returns the message structure of information about messages in the database. For example:

msgInfo = 

5x1 struct array with fields:

To get information on a single message by message name, type:

msgInfo = messageInfo(database name, 'message name')

This command returns information about the message as defined in the database. For example:

msgInfo = messageInfo(db, 'EngineMsg')

msgInfo = 

        Name: 'EngineMsg'
     Comment: ''
          ID: 100
    Extended: 0
      Length: 8
     Signals: {2x1 cell}

Here the function returns information about message with name EngineMsg in the database db. You can also use the message ID to get information about a message. For example, to view the example message given here by inputting the message ID, type:

msgInfo = messageInfo(db, 100, false)

This command provides the database name, the message ID, and a Boolean value for the extended value of the ID.

To learn how to use it and work with the database, see the messageInfo function.

View Signal Information in a CAN Message

You can get signal definition information on a specific signal or all signals in a CAN message with database definitions attached. Provide the message name or the ID as a parameter in the command:

sigInfo = signalInfo(db, 'EngineMsg')

You can also get information about a specific signal by providing the signal name:

sigInfo = signalInfo(db, 'EngineMsg', 'EngineRPM')

To learn how to use this property and work with the database, see the signalInfo function.

You can also access the Signals property of the message to view physical signal information. When you create physical signals using database information, you can directly write to and read from these signals to pack or unpack data from the message. When you write directly to the signal name, the value is translated, scaled, and packed into the message data.

Attach a CAN Database to Existing Messages

You can attach a .dbc file to messages and apply the message definition defined in the database. Attaching a database allows you to view the messages in their physical form and use a signal-based interaction with the message data.

To attach a database to a message, type:

 attachDatabase(message name, database name)

    Note:   If your message is an array, all messages in the array are associated with the database that you attach.

You can also dissociate a message from a database so that you can view the message in its raw form. To clear the attached database from a message, type:

 attachDatabase(message name, [])

    Note:   The database gets attached even if the database does not find the specified message. Even though the database is still attached to the message, the message is displayed in its raw mode.

For more information, see the attachDatabase function.

Was this topic helpful?