www.gusucode.com > vnt 源码程序 matlab案例代码 > vnt/demoVNT_ManageCANMessageGUI.m

    %% Manage CAN Message Data in a GUI
% This example shows you how to use Vehicle Network Toolbox(TM) to
% transmit and receive CAN messages and visualize CAN message data using a
% GUIDE GUI. This example uses Vehicle CAN Bus Monitor to display generated 
% messages. It uses Vector Virtual CAN channels connected in a loopback configuration.
% 
% Copyright 2011-2013 The MathWorks, Inc.


%%  Launch and Configure Vehicle CAN Bus Monitor
% Open Vehicle CAN Bus Monitor.
canTool

%% 
% To attach the database file, in the Vehicle CAN Bus Monitor window:
%
% * Select "Configure" > "Database...". 
% * Browse to your MATLAB installation folder and go to toolbox\vnt\vntdemos. 
% * Select |demoVNT_ManageCANMessageGUI.dbc|.

%%
% Verify that Vehicle CAN Bus Monitor is using the channel: "Vector - Virtual 1 - Channel 1":
%
% * Select "Configure" > "Channel".
% * Select "Vector - Virtual 1 - Channel 1".

%%
% Vehicle CAN Bus Monitor is now configured. Click "Start" on the toolbar 
% to set it online. To view CAN signal data as decoded with the database 
% while Vehicle CAN Bus Monitor is running, enable the "Show Unique Messages" 
% option via the toolbar. Now you can expand each row in the message table to
% view the live signal values.

%% Launch the Example GUI
% Open the GUI used in this example.
demoVNT_ManageCANMessageGUIFig

%% Use the Example GUI to Send Messages
% Click |Send Messages| to transmit a single instance of each CAN message. 
% The GUI sends information from two CAN messages:
%
% * "VehicleData" contains accelerator pedal position and engine speed signals.
% * "WheelSpeeds" contains wheel speed signals.

%% 
% Click |Repeat Messages| to send both messages at a fixed periodic rate. 
% Click it again to stop the transmission. Experiment with each button and 
% watch the values displayed on the GUI. You can also see the messages 
% in Vehicle CAN Bus Monitor as the occur.

%% Use the Example GUI to Receive Messages and Display Data
% The GUI receives the messages as they are transmitted. It uses the
% database definitions to decode signal data from both messages and
% displays the values in engineering units. The display updates at a fixed
% periodic rate. Each time the update occurs, the GUI receives all of the
% CAN message traffic since the last update and displays the most recently
% available data values. If no new values are available for a given signal,
% the last displayed value remains on the GUI.

%% GUI Implementation
% The GUI in this example is built using the standard GUIDE editor. The
% MATLAB code that drives the GUI is generated from GUIDE and then updated
% with the CAN message handling code. Review this GUIDE code to see how 
% the CAN messaging is implemented.
edit demoVNT_ManageCANMessageGUIFig