This example shows you how to create, receive and process messages using information stored in CAN database files. This example uses the CAN database file,
demoVNT_CANdbFiles.dbc .
Create and Process Messages Using Database Definitions
Open the Database File
Open the database file and examine the
Messages property to see the names of all message defined in this database.
View Message Information
Before attempting to open an DBC file, you'll need to determine what kind of file you are dealing with and whether it is even possible to open or view the file format. Answer: Files which are given the.DBC extension are known as Microsoft Visual FoxPro Database Container files, however other file types may also use this extension.
Use
messageInfo to view message information, including the identifier, data length, and a signal list.
You can also query for information on all messages at once.
View Signal Information
Use
signalInfo to view signal definition information, including type, byte ordering, size, and scaling values that translate raw signals to physical values.
![]()
You can also query for information on all signals in the message at once.
Create a Message Using Database Definitions
![]()
Specify the name of the message when you create a new message to have the database definition applied. CAN signals in this messages are represented in engineering units in addition to the raw data bytes.
View Signal Information
Use the
Signals property to see signal values for this message. You can directly write to and read from these signals to pack or unpack data from the message.
Change Signal Information
Write directly to the signal to change a value and read its current value back.
When you write directly to the signal, the value is translated, scaled, and packed into the message data using the database definition.
Receive Messages with Database Information
Attach a database to a CAN channel that receives messages to apply database definitions to incoming messages automatically. The database decodes only messages that are defined. All other messages are received in their raw form.
Receive Messages
Start the channel, generate some message traffic and receive messages with physical message decoding.
Stop the channel and clear it from the workspace.
Examine a Received Message
Inspect a received message to see the applied database decoding.
Extract All Instances of a Specified Message
Use MATLAB notation to extract all instances of a specified message by name.
Plot Physical Signal Values
Plot the values of database decoded signals over time. Reference the message timestamps and the signal values in variables.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |