BUSMASTER Tutorial PDF [PDF]

  • 0 0 0
  • Gefällt Ihnen dieses papier und der download? Sie können Ihre eigene PDF-Datei in wenigen Minuten kostenlos online veröffentlichen! Anmelden
Datei wird geladen, bitte warten...
Zitiervorschau

BUSMASTER Functionalities

BUSMASTER Tutorial

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.

2. Create a New Directory Start BUSMASTER Application. Go to File -> New, create a new directory to contain the new configuration. Name the file “Tutorial.cfx”. Then click [OK].

3. BUSMASTER development The creation of a new BUSMASTER application involves four key steps. 1) 2) 3) 4)

I.

Create a Database Configure Transmission Messages Create Nodes Create Node behavior

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.

Create Database Messages 1) Select the path in the tree view on the left, right-click on it, and select New Message. 2) Name the message “Test”, put the address 0x720 and the Message Length 8 Bytes then choose standard Frame format. You will get the tree as showing below.

Figure 1 : Database tree

3) Then select CAN -> Database -> Save and Import. 4) You can also add a signal by pressing New Signal. The window will now look like this in the Overall View :

2 Realized by: A. CHARKAOUI & M. BOUKHRIS

BUSMASTER Functionalities

3.

BUSMASTER Tutorial

Configure Transmission Messages 1) Select CAN -> Transmit -> Configure. 2) Click Add to create a Message Block. 3) Select Monoshot on Tx Mode under Block Details. If you choose Cyclic, the message will be sent periodically. 4) Keep Time Delay matched and choose 100 msec. It represents the time delay between two messages. If you choose Key, the message will be sent after pressing the key chosen. You can also choose delay between two messages blocks if you add more than one message. 5) Expand the Name / ID drop-down menu and select “Test(0x720)”. 6) Write the data in the Data Bytes (02 22 FD 01 00 00 00 00), then choose channel 1, and std in the type of data. Then click Add Message. 7) Click Update or check Auto Update.

Our message should now look like this in the Overall View:

Figure 2 : Configure Transmission Messages

3 Realized by: A. CHARKAOUI & M. BOUKHRIS

BUSMASTER Functionalities

4.

BUSMASTER Tutorial

Create Nodes 1) 2) 3) 4) 5)

Select CAN -> Node Simulation -> Configure to create new simulation. Right click on CAN Bus in the tree view on the left and choose New Simulated System. Name the simulation “Tutorial” and save it as SIM file. Right click on the simulation path and choose add Node. Name the Node “Node1”. Then click [OK].

You will get the tree as showing below.

Figure 3 : Node tree

5.

Create Nodes Behavior 1) On the Configure Simulated Systems, select Node1 and click Add New File. Name the file “Tutorial.cpp”. 2) Now you can add a C++ code. 3) Right click on Message Handlers in the tree view on the left, and click Add. Select the function created and copy the following code to the bottom zone and press Ctrl+S. RxMsg.m_unMsgID = 0x712; // 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] = 0xff; RxMsg.m_sWhichBit.m_aucData[1] = 0x01; RxMsg.m_sWhichBit.m_aucData[2] = 0x03; RxMsg.m_ucChannel = 1; SendMsg(*(STCAN_MSG*)(&RxMsg));

The editor should looks like this:

4) Click on Build and Load on the Configure Simulated Systems. 5) In the Handlers Details, choose Message Handlers and click on Enable Handler. 4 Realized by: A. CHARKAOUI & M. BOUKHRIS

BUSMASTER Functionalities

BUSMASTER Tutorial

6) Select CAN -> Connect in order to run the simulation. 7) Click on start or stop sending messages to send test message. 8) In the Message Window, the result will be shown. Our result should now look like this in the Overall View:

II.

Lin application 1. Introduction BUSMASTER can be used as master to transmit the master requests and as slave to respond to the requests. User can monitor/analyze the LIN messages using BUSMASTER. The following steps are required to configure the BUSMASTER for transmission of frame headers or transmission/reception of LIN messages.

2. Create LIN Database 1) Click LIN->DatabaseEditor, the LDF Editor interface will appear. 2) Click file->new and choose one of the following LIN Version: 1.3 or 2.0 or 2.1.

Figure 4 : LIN Editor

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

Figure 5 : Create Signal

4) Right click on the Unconditional Frame element and click 'New'->'Create Unconditional Frame'.

Figure 6 : Unconditional Frame

5) Choose the publisher and the subscriber. Schedule Table Configuration Configure Schedule Table window can be used to select schedule table/frame headers for transmission imported from the loaded LDF file if BUSMASTER is used as master. 1) To create Schedule Table right click on the Schedule Table element in the element view and click on 'New'->Create Schedule Table.

Figure 7 : Edit Schedule Table

6 Realized by: A. CHARKAOUI & M. BOUKHRIS

BUSMASTER Functionalities

BUSMASTER Tutorial

2) Choose the schedule table’s name, and select the unconditional frame already created. Then click OK.

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:

Figure 8 : Cluster Configuration

4. LIN Schedule Table Configuration LIN Schedule Table Configuration can be used to configure schedule tables imported from LDF file to transmit master requests. 1) To configure Schedule Table click LIN->Schedule Configuration. 2) Select the Schedule Table.

Figure 9 : Configure Schedule Table

5. LIN Controller Configuration BUSMASTER is connected to LIN physical channel via the LIN Controller. To select the controller: 1) Click LIN->Driver Section->{Driver} for instance “Vector XL”. 2) Configure your controller, then click LIN->Connect.

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

Figure 10 : Transmit Messages

Configure Master Requests: • Select the frame type as Master {DLC and data byte values will not be editable for frame Header}. Configure Slave Responses: • Select the frame type as Slave. • If the Message is a DB Messages and if it has signals associated, then they will be displayed in Signal List. Cyclic Transmission of the message: The message/frame header can be transmitted periodically by Enabling Repetition. Cyclic transmission will be useful to transmit the message with different data bytes periodically. Transmission on Event: The Message/frame header can be sent to the controller by pressing a key. Each message in Tx Frame List can be assigned to an alpha-numeric key.

Figure 11 : Message Transmited

8 Realized by: A. CHARKAOUI & M. BOUKHRIS

MFC GUI

III.

BUSMASTER Tutorial

MFC GUI GOAL: To gain understanding of the GUI API and basic MFC Dialog Window PREREQUISITES: C++.

1. Creating the dialog window 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 :

Figure 12 : Panel resource tree

2) Click on Panel.rc. In order to create your GUI, choose Dialog folder. 3) Click on Dialog folder -> Insert Dialog. You will get the view as in the following figure :

Figure 13 : Insert dialog

4) 5) 6) 7)

Inside the Panel Window, Click on the menu item View -> Resource View. Double Click on "IDD_DIALOG" to bring up the MFC Resource Editor. Select the main application window by clicking on the window. 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

Figure 14 : Adding a class

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.

2. Design the Panel 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:

Figure 15 : Example of panel

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”.

Figure 16 : Code to add in the ressource file

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: USAGEMODE HRESULT DIL_UDS_ShowdiagSession(HWND hParent) { CWnd objParent; if (dgsession == NULL) { dgsession = new DiagSession(); dgsession->Create(IDD_dialog_session); } dgsession->ShowWindow(SW_SHOW); objParent.Detach(); return 0; }

3. Programming your Panel 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: 1)

Click on “Id_Ressource_Variables”,add your parameter , in this example we will program the sub service (01), so our ID will be 1001.

Figure 17 : Add an ID

11 Realized by: A. CHARKAOUI & M. BOUKHRIS

MFC GUI 2)

BUSMASTER Tutorial

When you add your parameter, a function prototype is created with your parameter

Figure 18 : Node simulation's browser

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));

4. Communication between Node Simulator and the Panel 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) 3) 4) 5)

(Inside the Panel Window) Click the menu item View >> Resource View Double-Click on "IDD_dialog_session" to bring up the MFC Resource Editor Right-Mouse-Button click, select Add Event Handler... In the 'Event Handler Wizard' window, change : 1. 2. 3. 4.

Message Type to BN_CLICKED Class List to “Your Class Name” Function Handler Name to OnBnClickedBtnDgSession (just an example) Click Add and Edit

6) Within the OnBnClickedBtnDgSession() function, add the following code :

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:

Figure 19 : Example of Panel

13 Realized by: A. CHARKAOUI & M. BOUKHRIS

Design panel with QT

IV.

BUSMASTER Tutorial

Design panel with QT This section will present you how to design a panel using QT and communicate it with BUSMASTER.

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.

Figure 20 : QT Project Tree

2) The GUI will appear as follows :

Figure 21 : The Main Panel

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 :

Figure 22 : Add new tab

14 Realized by: A. CHARKAOUI & M. BOUKHRIS

Design panel with QT

BUSMASTER Tutorial

4) Now that your tab is added you can design your panel. An example of panel is shown below.

Figure 23 : Diagnostic Session Control Panel

2. Communicating the Panel with BUSMASTER Once the panel is designed, now we have to communicate it with BUSMASTER. We will continue on working at the Diagnostic Session Control. 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 :

Figure 24 : Adding the slot

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 :

Figure 25 : The slot function created

3) To send the ID copy the following code in the function : fichier.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream flux(&fichier); flux lineEdit_72->setText("1"); (replace lineEdit_72 by the ID of your line edit).

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);

Where MYVAR is the ID of the Line edit. 7) Once you have built your project, you have to copy the executable of the Main Panel and paste it on the Panel folder in the configuration folder as its showed in the following figure :

Figure 26 : Configuration folder

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