BUSMASTER Tutorial PDF
BUSMASTER Tutorial PDF
BUSMASTER Tutorial PDF
Table of Contents
1. Abstract ............................................................................................................................... 2
2. Create a New Directory....................................................................................................... 2
3. BUSMASTER development .................................................................................................. 2
I. CAN Application ...................................................................................................................... 2
1. Create a Database ............................................................................................................... 2
2. Create Database Messages ................................................................................................. 2
3. Configure Transmission Messages ...................................................................................... 3
4. Create Nodes ...................................................................................................................... 4
5. Create Nodes Behavior ....................................................................................................... 4
II. Lin application ......................................................................................................................... 5
1. Introduction ........................................................................................................................ 5
2. Create LIN Database ........................................................................................................... 5
3. Cluster Configuration .......................................................................................................... 7
4. LIN Schedule Table Configuration....................................................................................... 7
5. LIN Controller Configuration ............................................................................................... 7
6. Transmit Messages ............................................................................................................. 7
III. MFC GUI .............................................................................................................................. 9
1. Creating the dialog window ................................................................................................ 9
2. Clean Up GUI ........................................................................ Error! Bookmark not defined.
3. Creating your Panel........................................................................................................... 10
4. Programming your Panel .................................................................................................. 11
5. Communication between Node Simulator and the Panel ................................................ 12
IV. Design panel with QT ........................................................................................................ 14
1. Panel Design...................................................................................................................... 14
2. Communicating the Panel with BUSMASTER ................................................................... 15
1
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
1. Abstract
This is a step-by-step tutorial to introduce the basic process of developing a simple
BUSMASTER application. Used as a guide, the beginning user will get up the curve quickly.
3. BUSMASTER development
The creation of a new BUSMASTER application involves four key steps.
1) Create a Database
2) Configure Transmission Messages
3) Create Nodes
4) Create Node behavior
I. CAN Application
1. Create a Database
1) On the BUSMASTER menu, go to CAN -> Database -> New.
2) Save the file as DBF file called “Tutorial.dbc” in the directory just created.
2
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
Our message should now look like this in the Overall View:
3
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
4. Create Nodes
1) Select CAN -> Node Simulation -> Configure to create new simulation.
2) Right click on CAN Bus in the tree view on the left and choose New Simulated System.
3) Name the simulation “Tutorial” and save it as SIM file.
4) Right click on the simulation path and choose add Node.
5) Name the Node “Node1”. Then click [OK].
SendMsg(*(STCAN_MSG*)(&RxMsg));
4
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
6) Select CAN -> Connect in order to run the simulation.
Our result should now look like this in the Overall View:
3) Create a new signal, right click on the Signals element in the LDF element view and click
'New'. A dialog box will be shown as below:
5
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
4) Right click on the Unconditional Frame element and click 'New'->'Create Unconditional
Frame'.
3. Cluster Configuration
To Transmit\Receive the LIN Messages, BUSMASTER has to be configured with LIN Baud
Rate and Version. To enable master mode for LIN channel for transmitting frame headers,
check the Enable Master Mode under LIN Network Settings.
Click on LIN->Cluster Configuration menu. This will display the Window as shown in the
following figure:
6. Transmit Messages
The master can transmit frame headers and the slave can respond to the master’s requests
over LIN-bus using LIN Transmit Window.
1) Select LIN --> Transmit --> Configure menu option, to open the LIN Transmission
Window.
7
Realized by: A. CHARKAOUI & M. BOUKHRIS
BUSMASTER Functionalities BUSMASTER Tutorial
8
Realized by: A. CHARKAOUI & M. BOUKHRIS
MFC GUI BUSMASTER Tutorial
PREREQUISITES: C++.
Open the BUSMASTER solution with Visual Studio IDE. Once done follow these steps:
1) Click on Resource View. You will get the tree as showing bellow :
4) Inside the Panel Window, Click on the menu item View -> Resource View.
5) Double Click on "IDD_DIALOG" to bring up the MFC Resource Editor.
6) Select the main application window by clicking on the window.
7) Right-click on main application window -> Properties -> change :
a. ID to "IDD_dialog_session";
b. Caption to "MFC_DiagSession".
8) Right-click on the Dialog and select add a class. You will have to complete certain
information like shown in the figure bellow :
9
Realized by: A. CHARKAOUI & M. BOUKHRIS
MFC GUI BUSMASTER Tutorial
9) Get back to the MFC Resource Editor: Select the push-button ‘OK’ -> go to properties ->
change Caption to “Send”.
10) Select the push-button ‘Cancel’ -> go to properties -> change Caption to “Quit”.
11) Drag now "Quit" and “Send” button to the bottom-right corner of the dialog window.
12) Build the Solution by selecting the menu Build -> Build solution.
1) Drag from the toolbox a three Radio Buttons -> Bring up the Properties window of each
Radio Button -> rename each Caption like shown in the figure bellow:
2) Now that you have created your panel, you should integrate it in BUSMASTER interface.
To do so, you should follow this steps :
a. Go to the Visual Studio Menu -> Click View -> Solution Explorer.
b. Go to BUSMASTER Project -> Define your ID (IDD_dialog_session) in Ressource.h
file (in the header files folder).
c. Inside the file BUSMASTER.rc (in the source files folder), create your
“MENUITEM”. In the figure bellow you can see an example of panels already
created. You have to look for the POPUP “Panels”.
d. Now you have to associate your ID with a function which will show your panel. To do so,
go to MainFrm -> declare your function and associate it with an ID like showing in the
line bellow:
10
Realized by: A. CHARKAOUI & M. BOUKHRIS
MFC GUI BUSMASTER Tutorial
ON_COMMAND (YOUR ID (‘IDD_dialog_session’), YOUR FUNCTION (‘OnDiagSession’)).
e. Your function (OnDiagSession) in the main of BUSMASTER (MainFrm), will be like this:
void CMainFrame::OnDiagSession()
{
HRESULT Temp = DIL_UDS_ShowdiagSession(this->m_hWnd);
}
You will call an external function that (DIL_UDS_ShowdiagSession) you will create in the
main of the project Panel (in “main_panel.cpp”), it will be responsible of showing your
panel in BUSMASTER.
f. In the main_panel.cpp, you have to instantiate the dialog class, already created in
section two. For example: your class name is CDiagSession you will have to add :
CDiagSession * dgsession = NULL;
Now your function should look like the example bellow:
if (dgsession == NULL)
{
dgsession = new DiagSession();
dgsession->Create(IDD_dialog_session);
}
dgsession->ShowWindow(SW_SHOW);
objParent.Detach();
return 0;
}
In order to program it, we will use Node Simulator, where we will write our code source. As it is
mentioned before, it offers a browser where the user can write its code and simulates its
nodes.
So to make a link between the panel and the browser we give the user a parameter called
“Id_Ressource_Variables”, this parameter can represent the ID of a service and its sub service.
For example: we have our diagnostic session panel, which represent service 10 and it has tree
sub services (01-02-03).To program it we will follow these steps:
Figure 17 : Add an ID
11
Realized by: A. CHARKAOUI & M. BOUKHRIS
MFC GUI BUSMASTER Tutorial
2) When you add your parameter, a function prototype is created with your
parameter
3) Now it’s time to write your code, for this example, we need to send the frame 10
01 in CAN BUS :
Tester RxMsg;// Tester is a message from data base
RxMsg.m_unMsgID = 0x726; // Message ID
RxMsg.m_ucEXTENDED = FALSE; // Standard Message type
RxMsg.m_ucRTR = FALSE; // Not RTR type
RxMsg.m_ucDLC = 8; // Length is 8 Bytes
RxMsg.m_sWhichBit.m_aucData[0] = 0x02;//data to send
RxMsg.m_sWhichBit.m_aucData[1] = 0x10;
RxMsg.m_sWhichBit.m_aucData[2] = 0x01;
RxMsg.m_sWhichBit.m_aucData[3] = 0x0;
RxMsg.m_sWhichBit.m_aucData[4] = 0x0;
RxMsg.m_sWhichBit.m_aucData[5] = 0x0;
RxMsg.m_sWhichBit.m_aucData[6] = 0x0;
RxMsg.m_sWhichBit.m_aucData[7] = 0x0;
RxMsg.m_ucChannel = 1; //channel
SendMsg(*((STCAN_MSG *)&RxMsg));
After creating the panel and written its code, we must make a link between the Node Simulator
and the panel.
When the user push a button, the appropriate code written in the Node Simulator should be
executed. To achieve this, you must:
1) Go back to Panel project, inside your “class”.cpp, you should include different files to
use CAN interface, Node Simulator libraries and Panel external functions file
(Panel_Externe.h) where we have developed some functions that you can use.
2) (Inside the Panel Window) Click the menu item View >> Resource View
3) Double-Click on "IDD_dialog_session" to bring up the MFC Resource Editor
4) Right-Mouse-Button click, select Add Event Handler...
5) In the 'Event Handler Wizard' window, change :
12
Realized by: A. CHARKAOUI & M. BOUKHRIS
MFC GUI BUSMASTER Tutorial
GetICANNode()->NS_ManageOnIDHandler("1001");
When BUSMASTER is running, this function will search the ID "1001" in the Node
Simulator and then will use the CAN BUS interface to send the frame.
Each time you will have to change the parameter according to your code in Node
Simulator.
GetICANNode()->NS_ManageOnIDHandler("YourParameter");
7) In the Visual Studio project window, click Build >> Build Solution
Here you are an example of a main panel, where multiple services were implemented:
13
Realized by: A. CHARKAOUI & M. BOUKHRIS
Design panel with QT BUSMASTER Tutorial
1. Panel Design
To design your panel, you will have to use a QT project already created named Panel. It
contains a Main Panel which is a tabulation containing several panels. The work to do is to add
your own tab and design your panel on it.
To start your design, open the Panel project (file with extention .pro) and then:
1) Select ‘Forms’ -> double click on ‘panel.ui’. You will get the tree as showing below.
3) Right click on the last tab created (if you want to add your panel at the end) -> Click on
‘Insert Page’ -> ‘After Current Page’. It will appear as follows :
In order to program your panel in the node simulator, you have to send an ID which is a string.
To do so you have to:
1) Right Click on the ‘Default Session’ Radio Button -> ‘Go to slot…’ -> Select signal
‘Clicked’ and then click OK. The window will appear as follows :
2) Once selecting the slot, a function will be created automatically and you will be
switched to the file panel.cpp. It will appear as follows :
15
Realized by: A. CHARKAOUI & M. BOUKHRIS
Design panel with QT BUSMASTER Tutorial
6) If you want to read the content of a line edit or other and send it in order to be used in
the node simulation browser (send the content of this line edit), you have to use the
function ‘pathFinder’ as follows :
QString VAR;
VAR = ui->MYVAR->text();
pathFinder("MYVAR", VAR);
8) In BUSMASTER :
- Select CAN -> Node Simulation -> Configure -> Select your node ‘tester’ -> Click ‘Edit
File’;
- Right-click on ID_Ressources_Variables -> click Add;
- Add the ID that you have already send it in QT (“1001”);
- Click on the function created -> write the following code :
Tester RxMsg;
RxMsg.m_unMsgID = 0x726; // Message ID
RxMsg.m_ucEXTENDED = FALSE; // Standard Message type
RxMsg.m_ucRTR = FALSE; // Not RTR type
RxMsg.m_ucDLC = 8; // Length is 8 Bytes
RxMsg.m_sWhichBit.m_aucData[0] = 0x02; //DATA
RxMsg.m_sWhichBit.m_aucData[1] = 0x10;
RxMsg.m_sWhichBit.m_aucData[2] = 0x01;
RxMsg.m_sWhichBit.m_aucData[3] = 0x0;
RxMsg.m_sWhichBit.m_aucData[4] = 0x0;
RxMsg.m_sWhichBit.m_aucData[5] = 0x0;
RxMsg.m_sWhichBit.m_aucData[6] = 0x0;
RxMsg.m_sWhichBit.m_aucData[7] = 0x0;
RxMsg.m_ucChannel = 1;
SendMsg(*((STCAN_MSG *)&RxMsg));
Our function should now look like this in the Overall View:
16
Realized by: A. CHARKAOUI & M. BOUKHRIS
Design panel with QT BUSMASTER Tutorial
- If you want to use the content of the variable MYVAR and send it in the third byte
for example, use the function ‘Utils_GetValue’ as following :
RxMsg.m_sWhichBit.m_aucData[3] = Utils_GetValue("MYVAR");
17
Realized by: A. CHARKAOUI & M. BOUKHRIS